Skip to content

Conversation

@dprochownik
Copy link

When converting message to mail message using ToMailMessage method, attachments file names were taken only from property "attachmentMessagePart.ContentType.Name".

Unfortunatelly when this propery was null then attachement file name in new mail message object was also null, although it could be read from "attachmentMessagePart.FileName".
I can't tell you which e-mail client generates such EML messages without attachmentMessagePart.ContentType.Name but I got one from on of my bussiness client. Unfortunatelly it's confidential so I can't post it here.

@foens
Copy link
Owner

foens commented Jan 26, 2015

Your code actually modifies the MessagePart. If I was calling ToMailMessage, I would not expect it to modify the original content. It would be wise to clone the ContentType instead.

@jstedfast
Copy link

The filename parameter on the Content-Disposition header is what you should be using as your primary property for the name of the file to use on the file system.

The name parameter on the Content-Type header is more of a "display name" and can be different (or, as in your message, not even set).

By convention, when a mail client saves to disk, it will first check the Content-Disposition filename parameter. If that is not set, it will fall back to the name parameter on the Content-Type, and, failing that, will simply prompt the user.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants