Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error initiating communication with Smtp server. (501)

Status
Not open for further replies.

stergiosnik

Technical User
Sep 19, 2007
64
GR
Hello.

I am trying to send email using a Microsoft Access 2007 with a special code utlity from AXOSOFT.

I get this error message: "Error initiating communication with Smtp server. (501)"

I tested the mail server using Outlook Express and it works fine.

Any ideas what might be the problem that causes this error message?

Next follows a sample of part of the code used:


private static void sendEmail(MailMessage msg, string email)
{

Smtp smtp = new Smtp();

msg.EmailFrom = "myname@myname.gr";

msg.AddEmailTo(email); // pou 8a fugei to email?

msg.EmailMessageType = MessageType.HTML;

msg.EmailSubject = "Personal Schedule for FALL'13";

smtp.SmtpServer = "mail.myname.gr";

smtp.SmtpUser = "myname";

smtp.SmtpPassword = "0000000";

if (!regno.Contains("EX")) { smtp.SendEmail(msg); Thread.Sleep(1000); Console.WriteLine("Sended Number : " + sendCount + " with email : " + email + " and reg:" + regno); }

sendCount++;


}
 
Erm ... this doesn't look like VB. Seems to be C#

But off the top of my head you AXOSOFT have simply provided a wrapper for .NET's SMTP assembly. So I'm pretty sure it isn't SMTP itself that is at fault. And error 501 normally suggests a syntax error in the SMTP parameters or arguments.

Quick question: what happens if you try

msg.EmailMessageType = MessageType.Text;

rather than

msg.EmailMessageType = MessageType.HTML;


 
Can I ask why you don't send your email using the CDO or Outlook library instead of this special utility?
 
> using the CDO or Outlook library

As I pointed out, he's using C##, so talking to COM libraries is not quite as straightforward as from VB6. In addition the OP may be operating in an environment that does not allow unmanaged code components.

On the other hand he could use .NETs SMTPClient class, which I initially erroneously assumed the Axosoft utility was wrapping. However Axosoft maintain that they had problems with the SMTPClient code, which is why they wrote their own minimalist replacement.

But we are moving way beyond the remit of this forum here.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top