Email : EMail : Network C# Examples


C# Examples » Network » EMail »

 

Email









    
using  System;
using  System.Collections.Generic;
using  System.Collections.Specialized;
using  System.IO;
using  System.IO.Compression;
using  System.Net;
using  System.Net.Mail;
using  System.Net.Sockets;
using  System.Runtime.InteropServices;
using  System.Text;

public  class  MainClass
{
        public  static  void  Main()
        {
                SmtpClient  client  =  new  SmtpClient("smtp.localhost.com");

                client.Credentials  =new  NetworkCredential("username",  "password");

                MailMessage  message  =  new  MailMessage(new  MailAddress("joe@net.com",  "Joe"),        //  To
                        new  MailAddress("raj@web.com",  "Ray"));  //  CC
                message.Bcc.Add(new  MailAddress("a@asdf.com"));
                message.Bcc.Add(new  MailAddress("m@fda.com"));
                message.Subject  =  "subject";
                message.Body  =  "body";

                Attachment  att  =  new  Attachment(@"c:\file.cs");
                message.Attachments.Add(att);

                client.Send(message);
        }
}
    
   
  
   




HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Network
» EMail