I have to parse an email that has an attachment that was forwarded on as an embedded email which in turn has embedded attachments. I have the following code to try to process this, but when I come to the line that displays the attachedMessage.Attachments.Count, it comes back as 0.
var msgCollection = client.ListMessages();
var sequenceNumber = 0;
foreach (var msgInfo in msgCollection)
{
// Get
an individual email message
sequenceNumber++;
var msg = client.FetchMessage(sequenceNumber);
msg.Save(@“C:\test.msg”, MailMessageSaveType.OutlookMessageFormat);
foreach (var attachment in msg.Attachments)
{
// If the attachment is actually an embedded email message
var attachmentFileInfo = new FileInfo(attachment.Name);
if (attachmentFileInfo.Extension == “.eml”)
{
// List the attachments in the attached email
var attachedMessage = MailMessage.Load(attachment.ContentStream); Console.WriteLine(attachedMessage.Attachments.Count);