Sending Email with Credentials

I am trying to send mail to a server that requires credentials to send through. However, C# seems to be having issue with my code.

I sent email successfully through another server without authentication, so i know that that portion of code works. I sent email successfully from Outlook Express using the username / password combo through the authenticated server, so i know my username/password is valid.

-------------- Start Code Snippet -------------------

System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage();

msg.From = new System.Net.Mail.MailAddress(sMailFrom, "Application Change Request");

msg.To.Add(sMailTo);

msg.Subject = "Application Change Request";

msg.Body = sMailBody;

System.Net.Mail.SmtpClient scSend = new System.Net.Mail.SmtpClient(sSMTPServer);

scSend.Credentials = new System.Net.NetworkCredential(sSMTPUserName, sSMTPPassword);

scSend.Send(msg);

lblMessageSent.Visible = true;

-------------- End Code Snippet -------------------

I continuously get "Relayed Denied" from the server when trying to send email using this code. Any advice

Thanks in advance,

Trevor Watson



Answer this question

Sending Email with Credentials

  • Kishore Babu Annavarapu

    Thanks for your response. I did find the issue.

    The server does require authentication, but my ISP seemed to be blocking traffic to email ports that are not on their server and not using a standard email client. go figure.

    Trevor Watson


  • cmn

    Can u please check in your outlook whether your SMTP server requires Authintication.

  • Sending Email with Credentials