Adding an attachment to email using C#

前端 未结 4 1489
广开言路
广开言路 2020-12-01 13:45

I\'m using the following code from this answer Sending email in .NET through Gmail. The trouble I\'m having is adding an attachment to the email. How would I add an attachme

4条回答
  •  感动是毒
    2020-12-01 14:22

    Correct your code like this

    System.Net.Mail.Attachment attachment;
    attachment = new System.Net.Mail.Attachment("your attachment file");
    mail.Attachments.Add(attachment);
    

    http://csharp.net-informations.com/communications/csharp-email-attachment.htm

    hope this will help you.

    ricky

提交回复
热议问题