+1 vote

How do I specify an alternative filename for an attachment instead of using the same file name which automatically is used while adding a file as attachment?

string filePath = "C:\\Test.pdf";
MailBuilder builder = new MailBuilder();
builder.AddAttachment(filePath);  

but I want to have "XYZ.pdf" as file name, which is shown for this attachment in the email client which received the mail.

by

1 Answer

0 votes
 
Best answer

Use the return value of AddAttachment method (MimeData instance) and
set its FileName property to change the attachment name:

string filePath = "C:\\Test.pdf";
MailBuilder builder = new MailBuilder();

MimeData mime = builder.AddAttachment(filePath);
mime.FileName = "anything.pdf";
by (301k points)
...