There are 3 "name" properties on the .NET Attachment class:
Attachment.Name
Attachment.ContentType.Name
Attachment.ContentDisposition.FileName
I want to send an excel file with the name "foo.xls". Which of these should be set? What's the difference? The docs are not particularly illuminating.
The correct one to use is Attachment.Name.
Info for Attachment.ContentType.Name -
When specifying content for a Attachment as a Stream or String, you can use Name to set the name of the file that stores the content on the recipient's system
Info for Attachment.ContentDisposition.FileName -
The FileName property allows the sender to suggest the name to be used to store an e-mail attachment on the recipient's computer. This name is a suggestion only; the receiving system can ignore it. The name must not include path information; any such information is ignored by the receiving computer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With