Sunday, April 3, 2011

how to attach the pdf file that is present in program file throught mail

Hello,

am generating a pdf file in my c# code... i want to attach that pdf file and same to my mail id using attachment... can anyone help me in sending pdf through attachment internally using c# code

thank you

From stackoverflow
  • You can attach your pdf file as :

    MailMessage message = new MailMessage();
    message.To = "mailgoesto@domain.com";
    message.From = "mailcomesfrom@domain.com";
    message.Subject = "mail with pdf";
    message.Body = "your pdf attached";
    message.Attachments.Add(new Attachment(@"c:\pdftoattach.pdf"));
    
    SmtpMail.SmtpServer = "mail.domain.com";
    SmtpMail.Send(message);
    

0 comments:

Post a Comment