I want to download email messages to files, and that the file contains the attached files

Hi.
Looking to download email messages (to files) I only saw the SaveMailMessage activity. It says it returns .eml files. I tried to go down to msg extension and it gives me error.
I do not download attachments in email messages. It doesn’t have many properties, so I don’t know how to get it to download the file with the complete email messages (with the attached files).
Can you help me?
Thank you

Hi,
I will speak for the outlook automation.

First of all you should use Get Outlook Mail Messages activity for take those mails. Output will be a List.

Then put a for each activity, type that mailmessage list to property of “values”. Change the “TypeArgument” property to System.Net.Mail.MailMessage

Then item will be your one mail message. Inside of for each use Save Mail Message for saving .msg files. MailMessage property will be “item”. And type your saving path.

After that put a save attachments activity. Folder path will be your saving folder, message will be item. If you want specific attachments like .xml or .pdf files you can type a regex code in filter property. Output of save attachments will be an array(or list i don’t remember) of attachments path.

I hope I could tell.

1 Like

Hi, Ercanebiler.

I prove with this that you wrote me, it seems interesting.

Thank you

I didn’t understand what you mean :slight_smile: Also in the forum when you type to someone use @ character :slight_smile:

I meant … very interesting.
I test with your information.
Thank you

So it worked? :slight_smile:

No.
It returns a file with an .msg extension. But I can’t open it. It gives me an error. That the message is already open or that I lack permissions

I speak in spanish

Please get text this and translate to English :slight_smile:

Google Translation:
“We cannot open (folder name). The file may be open or you don’t have permission to open it.
To verify permissions, right-click the file folder, then click Properties”

Are you trying to open it manually?

Yes.

@MarceloPassadore (and @ercanebiler for continuity), I actually had a very similar request come from a customer. Naturally, I came across this post and decided to jump in. Long story short, the .NET method only gets us so far within the email message itself and to get to another one might be a crazy amount of configurations. Furthermore, if you can’t open the .msg at all, that is an Outlook specific constraint to confirm what was expressed above.

However, I wanted to share a nice little workaround using “Start Process” to open the email attachment itself and THEN use the GUI to save the attachment you need. Feel free to take a look at the workflow attached.

Extract Attachment From Email Attachment_Workflow.zip (590.8 KB)

Dont want to be lazy but sometimes is nature, i can see this little code inside a for each email:

SmtpClient client = new SmtpClient("mysmtphost");
client.DeliveryMethod = SmtpDeliveryMethod.SpecifiedPickupDirectory;
client.PickupDirectoryLocation = @"C:\somedirectory";
client.Send(message);

And the messages would get saved in disk.