Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct attachment file name whien message content type name is null or ... #29

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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