Adding an attachment to email using C#

前端 未结 4 1485
广开言路
广开言路 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:08

    The message object created from your new MailMessage method call has a property .Attachments.

    For example:

    message.Attachments.Add(new Attachment(PathToAttachment));
    

提交回复
热议问题