TomTee
TomTee

Reputation: 101

Using MailKit, attachments with unicode file names appear as "untitled attachment" in Outlook

We are using MailKit in our application to send e-mails to users. These e-mails often have attachments with Unicode or long file names. Some e-mail clients, such as Outlook (when using POP or IMAP) or Outlook Express, cannot handle RFC 2231, and the result is that the attachments have names 'Untitled Attachment'.

Is there a way to send mails (using MailKit) supporting RFC 2047 (encoded-words) for attachments file names? A possible solution would be to keep RFC 2231 in filename in content-disposition, but use as a fall-back an encoded-word encoded name parameter in content-type. Is something like this supported?

Upvotes: 5

Views: 2062

Answers (1)

jstedfast
jstedfast

Reputation: 38608

I've just added support for using rfc2047 encoding to MimeKit.

There are now 2 ways of controlling the encoding method used for parameter values.

The first way is to set the encoding method on each individual Parameter:

param.EncodingMethod = ParameterEncodingMethod.Rfc2047;

The second way is to set the default parameter encoding method on the FormatOptions used for writing out the message and/or MIME part(s):

var options = FormatOptions.Default.Clone ();
options.ParameterEncodingMethod = ParameterEncodingMethod.Rfc2047;

message.WriteTo (options, stream);

I'll try to release a new MimeKit 1.3.0-beta3 to nuget soon with this feature.

Upvotes: 2

Related Questions