readonly Dictionary<string, MailMessageFormat> EmailFormatMap = new Dictionary<string, MailMessageFormat>
{
{ "application/vnd.ms-outlook", MailMessageFormat.Msg }, // .msg formatı
{ "message/rfc822", MailMessageFormat.Eml } // .eml formatı
};
MemoryStream inputStream = new MemoryStream();
FileManager.WriteToStream(FileContent, ref inputStream);
MailMessageFormat fileformat = EmailFormatMap.TryGetValue(ItemAttachment.FileType, out var format) ? format : MailMessageFormat.Eml;
var message = MailMessage.Load(inputStream, fileformat );
There is no problem when MailMessageFormat.Eml
is passed as the second parameter to the Load
method, but when MailMessageFormat.Msg
is used, I get the following error.
System.Collections.Generic.KeyNotFoundException: 'The given key was not present in the dictionary
Thank you for your help!