Anthony Breen · Nov 19, 2020

How to read an attachment file that is part of an attached email


I'm processing POP3 emails using the standard EnsLib.EMail.InboundAdapter adapter and %Net.MailMessage. I'm basically processing documents that are attached to received emails. This works fine if the document is simply attached to the email itself. But some systems are sending documents that are attached to an attached email which has content-type = message/rfc822.

How do I get the attached file from the attached email?

I'm using the following code to iterate through the email parts.. I can get as far as processing a MailMessagePart which has content-type = message/rfc822 but how do I process it as it's not really a MailMessagePart?

If pInput.IsMultiPart {
        Set tPartsCount = pInput.Parts.Count()
        $$$LOGINFO("This message has multiple parts; " _ tPartsCount)
        For tInd = 1:1:tPartsCount {
          Set tStatus = ..ProcessPart(pInput.Parts.GetAt(tInd),pInput.Subject,pInput.From,.attachedFilename,.status,.errorText)


1 0 1 49


It's okay. I worked it out.

Just needed to call a method from the POP3 mail server that's accessible using the Adapter.