Monday, March 26, 2012

SMTP server is not available!

I have a problem when using STMP protocol to send mail: Exception occur: "System.Web.HttpException: The message could not be sent to the SMTP server. The transport error code was 0x80040217. The server response was not available".
Hmm How to : Check to be sure the server System.Web.Mail is executing on can connect to the mail server and The server specified in the SmtpServer property is not valid or not available ??

Why? please help me. thank very much!

regards!

camtu

Check this Code Below...

I hope it helps You...Smile

using System.Web.Mail;

using System.Web.Configuration; publicvoid SendMail(string From,string To,string Subject,string MessageBody)

{

MailMessage message =newMailMessage();

message.From = From;

message.To = To;

message.Subject = Subject;

message.BodyFormat =MailFormat.Html;

message.Body = MessageBody;

message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate","1");//basic authentication

string fromfire=ConfigurationSettings.AppSettings["mailfrom"]; //Picking from web.config

string fromfireepwd=ConfigurationSettings.AppSettings["mailfrompassword"];

message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", fromfire);//set your username here

message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", fromfireepwd);//set your password here

SmtpMail.SmtpServer=ConfigurationSettings.AppSettings["CompanyEmail"]; //Smtp Server Address

SmtpMail.Send(message);

}


hi;

could you post the parameters you have set for the smtp server?

Shivam


<appSettings>

<addkey="mailfrom"value="// E-Mail'>abcd@.yahoo.com"/>// E-Mail

<addkey="mailfrompassword"value="jat3434123"/> //E-mail pwd

<addkey="CompanyEmail"value="mail.jkt.com"/> //Smtp server address

</appSettings>

1) Check the server address and user name and password

one reason could be

2) a wrong username or password for the SMTP server an
usually means that the server has disabled your account for spamming
you've sent 1500 mails


You can check your server is responding or not in Command Prompt

command prompt ->[write] ping your server name or ip address

if it display Reply from then its OK or Responding

0 comments:

Post a Comment