Problem - Not able to retreive the email address from the attached signed email
((MimeKit.MessagePart)item).Message.To
Here is the code, the saved attachments does not have the email address; but only friendly name -
if (fileattachment.Name == "smime.p7m")
{
// Load & read 'smime.p7m'
fileattachment.Load();
using (MemoryStream memoryStream = new MemoryStream(fileattachment.Content))
{
MimeMessage mimeMessage = MimeMessage.Load(ParserOptions.Default, memoryStream);
foreach (var bodyPart in mimeMessage.BodyParts)
{
//HTML
if (!bodyPart.IsAttachment)
continue;
if (bodyPart is MessagePart)
{
//Subject is file name
var fileName = ((MimeKit.MessagePart)bodyPart).Message.Subject + ".eml";
var rfc822 = (MessagePart)bodyPart;
if (string.IsNullOrEmpty(fileName))
fileName = "attached-message.eml";
using (var stream = File.Create(fileName))
rfc822.Message.WriteTo(stream);
}
else
{
var part = (MimePart)bodyPart;
var fileName = part.FileName;
using (var stream = File.Create(fileName))
part.Content.DecodeTo(stream);
}
}
} //MemoryStream
}
Thanks in advance