how to send attachment in mail

Hello Friends,

I have write an article on mail sending functionality but i didn’t add attachment in it.
You can check it from here

Today I am going to describe how to send attachment in mail using
see the below code for mail attachment functionality:

    MailMessage Msg = new MailMessage();  
    Attachment attchment = new Attachment(physicalfilepathcomeshere);
    Msg.From = new MailAddress("fromemailaddress");  
    Msg.Subject = "Define your subject line";  
    Msg.Body = "Content of body";  
    SmtpClient smtp = new SmtpClient();  
    smtp.Host = "";  
    smtp.Port = 587;  
    smtp.Credentials=new System.Net.NetworkCredential("gmailID","gmailpassword");  
    smtp.EnableSsl = true;  

you need to provide physical file path in place of “physicalfilepathcomeshere”.

Hope this will help you in sending mail attachment.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>