Click here to Skip to main content
15,176,980 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I cannot use System.Net.Mail because I must connect with Servers that use Implicit SSL but System.Net.Mail does not support it.

Therefore I am forsed to use the old deprecated library too

I add an attachment like this:

System.Web.Mail.MailAttachment attachment = new System.Web.Mail.MailAttachment(AttachmentPath);

System.Web.Mail.MailMessage mailMsg = new System.Web.Mail.MailMessage();
....
mailMsg.Attachments.Add(attachment);

But I want to make it attach as a different name:
the actual file name is very long and confusing because it is a temporary file.
I would like it to attach such as "SalesOrderNo1.pdf",
is there a way to do this without having to make a copy of the file with high risk of file name collision ?

I know that System.Net.Mail.Attachment has property Name to set attachment title.
Instead System.Web.Mail.MailAttachment only has a readonly property Filename returns loaded file path.

Thanks
Posted

1 solution

this works good..
C#
attachment.Name = "SalesOrderNo1.pdf"; 
mailMsg.Attachments.Add(attachment);
   
v2
Comments
riccardo68 27-Jun-14 9:25am
   
do you read all ?

I know that System.Net.Mail.Attachment has property Name to set attachment title.
Instead System.Web.Mail.MailAttachment only has a readonly property Filename returns loaded file path.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900