Skip to content

Mail coding?

magesh manavalan

Asked Mar 16, 2012, 9:52 PM EDT3 answers
Share
LinkedInX
Hi i need mail coding with Example so pls send me soon as possible


Thanks&Regs

Magesh

3 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • Senthilkumar
    0
    Hi,

    The MailMessage comes under the namespace of System.Net.Mail.

    Here is the sample code to send email.

    VB.NET
    MailMessage message = new MailMessage();
    message.From = new MailAddress("[email protected]");
    
    message.To.Add(new MailAddress("[email protected]"));
    message.To.Add(new MailAddress("[email protected]"));
    message.To.Add(new MailAddress("[email protected]"));
    
    message.CC.Add(new MailAddress("[email protected]"));
    message.Subject = "This is my subject";
    message.Body = "This is the content";
    
    SmtpClient client = new SmtpClient();
    client.Send(message);


    System.Net.Mail reads SMTP configuration data out of the standard .NET configuration system (so for ASP.NET applications you'd configure this in your application's web.config file).  Here is an example of how to configure it:

     

      <system.net>

        <mailSettings>

          <smtp from="[email protected]">

            <network host="smtpserver1" port="25" userName="username" password="secret" defaultCredentials="true" />

          </smtp>

        </mailSettings>

      </system.net>

     

    Please go through this url. The MSDN has given the methods and properties of the MailMessage class with an code.

    http://msdn.microsoft.com/en-us/library/system.net.mail.mailmessage.aspx 




    0
  • 0
    Hi i try it ur code but i get errors pls send simple mail code with example.
    0
  • Senthilkumar
    0
    It may not be issue with the code. But when you use the email sending it will have some configuration/system environment issues.

    Please post the error which you are getting...
    0