I am trying to get the attachment from an .eml file.
The eml file is saved locally in my machine. I need to extract the attachment and attach it to MailMessage.
Able to attach the whole .eml file like below
MailMessage message = new MailMessage();
MemoryStream ms = new MemoryStream();
//storing the .eml into this ms 'memory stream'
ms.Position = 0;
message.Attachments.Add(new Attachment(ms, attachmentName));
But, i only need the attachment which is inside this .eml file. How to get that ? (As a memorystream)
---Edit---
Need to load the attachment which is inside the .eml file into the memorystream.
---Edit---
I found this qn somewhat similar. EML Parser
Advanced MIME Parser/Creator/Editor
But, couldn't get the proper solution to my problem. I think below is the issue.
Gets attachment entities. Entity is considered as attachmnet if:
*) Content-Disposition: attachment (RFC 2822 message)
*) Content-Disposition: filename = "" is specified (RFC 2822 message)
*) Content-Type: name = "" is specified (old RFC 822 message)