4

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?

TomTee
  • 91
  • 9

1 Answers1

2

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.

jstedfast
  • 35,744
  • 5
  • 97
  • 110
  • Tested both methods and the second one doesn't seem to work. More info here https://github.com/jstedfast/MimeKit/issues/291 – Tadas Šukys Nov 14 '17 at 13:17