Click here to Skip to main content
13,043,491 members (52,022 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Web Config:

      <smtp from=""  >
        <network host="" port="25"  userName="" password="xxxxx" />
  </> Code

MailMessage message = new MailMessage(FromMail, strTomail);
               message.Subject = "Feedback";
               message.IsBodyHtml = true;
               message.Body = "Dear <b>Admin</b>,<br><br> A feedback has been received with the following details:";
               SmtpClient smtp = new SmtpClient();
               smtp.EnableSsl = true;

Error I get like this:
The requested address is not valid in its context :
Posted 30-Jan-13 1:28am
Updated 30-Jan-13 2:40am
ryanb31 30-Jan-13 7:49am
The error has a different IP than what you specified so it sounds like you have a network issue you need worked out by your network admin.
OPees 30-Jan-13 22:51pm
Thanks ryan,

I ask Network admin but he is saying some other site mail configuration are working with same setting.!!i change my codes still there is same problem..

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

hi dear,
Please use below secure mail function
public bool SendEmialWithSecure(string ToEmailId, string FromEmailId, string FromName, string SenderEmailId,
       string SenderName, string Subject, string MailBody, string SMTPHost, Int32 SMTPPort,
       string CredentialEmailId, string CredentialPassword, string strAttachment)
       System.Net.Mail.MailMessage ResetPassMail = new System.Net.Mail.MailMessage();
       SmtpClient SmtpServer = new SmtpClient();
       ResetPassMail.To.Add(new MailAddress(ToEmailId));
       ResetPassMail.From = new MailAddress(FromEmailId, FromName);
       ResetPassMail.Sender = new MailAddress(SenderEmailId, SenderName);
       ResetPassMail.Subject = Subject;
       ResetPassMail.IsBodyHtml = true;
       ResetPassMail.Body = MailBody;
       ResetPassMail.Priority = System.Net.Mail.MailPriority.High;
       Attachment attach = new Attachment(strAttachment);
       SmtpServer.Host = SMTPHost;
       SmtpServer.Port = SMTPPort;
       SmtpServer.Credentials = new NetworkCredential(CredentialEmailId, CredentialPassword);
       SmtpServer.DeliveryMethod = SmtpDeliveryMethod.Network;

           return true;
       catch (Exception ex)

           throw ex;

OPees 3-Feb-13 23:05pm
Thanks Mahesh...!!
OPees 11-Feb-13 3:21am
Hello Mahesh,
i got this Error
The remote certificate is invalid according to the validation procedure

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 30 Jan 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100