Set Email Attachment name in C#

前端 未结 2 568
无人共我
无人共我 2021-02-11 13:00

I add an attachment like this:

System.Net.Mail.Attachment attachment = new System.Net.Mail.Attachment(AttachmentPath);   
msg.Attachments.Add(attachment);   
         


        
2条回答
  •  难免孤独
    2021-02-11 13:49

    How about:

    System.Net.Mail.Attachment attachment = new System.Net.Mail.Attachment(attachmentPath);
    attachment.Name = "file.txt";  // set name here
    msg.Attachments.Add(attachment);
    

提交回复
热议问题