Sending Mail over Intranet
-
Hello Friends, I'm sending mail using the following code and mail is working fine. SmtpClient client = new SmtpClient(); string from = "manoj.msb1984@gmail.com"; MailAddress From = new MailAddress(from); //To whom the mail is being sent string to = "depth.heart@gmail.com"; MailAddress To = new MailAddress(to); //To whom Carbon copy is being sent if there is not don't write this code //string cc = "rawgirish@gmail.com"; //MailAddress Cc = new MailAddress(cc); //Creat an object for MailMessage MailMessage message = new MailMessage(From, To); //Set Message body HTML true otherwise sometime it send html code message.IsBodyHtml = true; //Add Your Subject message.Subject = "Add You Subject Here"; //Add Body of the Mail here string strBody = "Hello, This is Manoj Bisht <br> Got It"; message.Body = strBody; try { //Send the Mail client.Send(message); //Show sent message if mail is sent successfully Response.Write("Mail Sent Successfully"); } catch (Exception ex) { Response.Write(ex.Message.ToString()); } But when im using this code to send email over intranet it's throwing error as shown below {"Failure sending mail."} [System.Net.Mail.SmtpException]: {"Failure sending mail."} Data: {System.Collections.ListDictionaryInternal} HelpLink: null InnerException: {"Unable to connect to the remote server"} Message: "Failure sending mail." Source: "System" StackTrace: " at System.Net.Mail.SmtpClient.Send(MailMessage message)\r\n at Rough_New.cmdSend_Click(Object sender, EventArgs e)" TargetSite: {Void Send(System.Net.Mail.MailMessage)}
-
Hello Friends, I'm sending mail using the following code and mail is working fine. SmtpClient client = new SmtpClient(); string from = "manoj.msb1984@gmail.com"; MailAddress From = new MailAddress(from); //To whom the mail is being sent string to = "depth.heart@gmail.com"; MailAddress To = new MailAddress(to); //To whom Carbon copy is being sent if there is not don't write this code //string cc = "rawgirish@gmail.com"; //MailAddress Cc = new MailAddress(cc); //Creat an object for MailMessage MailMessage message = new MailMessage(From, To); //Set Message body HTML true otherwise sometime it send html code message.IsBodyHtml = true; //Add Your Subject message.Subject = "Add You Subject Here"; //Add Body of the Mail here string strBody = "Hello, This is Manoj Bisht <br> Got It"; message.Body = strBody; try { //Send the Mail client.Send(message); //Show sent message if mail is sent successfully Response.Write("Mail Sent Successfully"); } catch (Exception ex) { Response.Write(ex.Message.ToString()); } But when im using this code to send email over intranet it's throwing error as shown below {"Failure sending mail."} [System.Net.Mail.SmtpException]: {"Failure sending mail."} Data: {System.Collections.ListDictionaryInternal} HelpLink: null InnerException: {"Unable to connect to the remote server"} Message: "Failure sending mail." Source: "System" StackTrace: " at System.Net.Mail.SmtpClient.Send(MailMessage message)\r\n at Rough_New.cmdSend_Click(Object sender, EventArgs e)" TargetSite: {Void Send(System.Net.Mail.MailMessage)}
Where is your SMTP Server name ? Does your SMTP in local Intranet configured properly ?
Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you.
-
Where is your SMTP Server name ? Does your SMTP in local Intranet configured properly ?
Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you.
-
<mailSettings> <smtp> <network host="192.168.1.8" port="25" userName="myuserName" password ="1234"></network> </smtp> </mailSettings>
.NET- India wrote:
InnerException: {"Unable to connect to the remote server"}
Your exception says that, you system is not able to connect with the remote server. Please check the connectivity between them.
Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you.