Send an email out : EMail : Network C# Examples


C# Examples » Network » EMail »

 

Send an email out









    
using  System;
using  System.Net;
using  System.Net.Mail;

class  MainClass
{
        public  static  void  Main(string[]  args)
        {
                SmtpClient  client  =  new  SmtpClient("mail.somecompany.com",  25);

                client.Credentials  =new  NetworkCredential("user@somecompany.com",  "password");

                using  (MailMessage  msg  =  new  MailMessage())
                {
                        msg.From  =  new  MailAddress("author@aaa.com");
                        msg.Subject  =  "HI";

                        msg.Body  =  "A  message";

                        msg.Attachments.Add(new  Attachment("c:\\test.txt",  "text/plain"));
                        msg.Attachments.Add(new  Attachment("C:\\test.exe",  "application/octet-stream"));

                        msg.To.Add(new  MailAddress("message  to  address"));
                        client.Send(msg);
                }

        }
}
    
   
  
   




HTML code for linking to this page:

    Related in same category :
Follow Navioo On Twitter

C# Examples

 Navioo Network
» EMail