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 Mike Lewis 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 Microsoft Access 2007 with a special code utility 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:

Thank you in advance.

Stergios.

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++;


}
 
Does your smtp server require ssl perhaps?
Here is a snippet I am using send mail via googlemail using .Net.Mail component:
Code:
SmtpClient smtp = new SmtpClient("smtp.gmail.com", 587);
[b]smtp.EnableSsl = true;[/b]
smtp.UseDefaultCredentials = false;
smtp.Credentials = new NetworkCredential(from, pass);
smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;

Try with enabled ssl.

Cheers,
MakeItSo

“Knowledge is power. Information is liberating. Education is the premise of progress, in every society, in every family.” (Kofi Annan)
Oppose SOPA, PIPA, ACTA; measures to curb freedom of information under whatever name whatsoever.
 
The OP is not using the .NET SMTPClient. They are using some utility code from AXOSOFT, which does not include the ability to configure using SSL.

The original article for this code is here (and shows the possibly flawed thinking as to why AXOSOFT developed their own SMTP code), and if we read the comments we can see that many people have the 501 problem. It seems to be related to how the code is handling EHLO, and there are at least two suggested modifications to the code suggested in the comments to fix this

e.g. change
[tt]WriteBuffer(ns, "ehlo\r\n");[/tt]
to
[tt]WriteBuffer(ns, "helo " + _serverSmtp + "\r\n"); [/tt]

of course the main recommendation might be to stop using AXOSOFT's utility (which frankly isn't actually properly SMTP-compliant), and to indeed use SMTPClient
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top