Save email .eml in csv

I want to read in all emails from my mail account, and save every email in its .eml format in a column of a csv. So every row should contain the .eml output in textual form.

How can I do this?

2 Likes

Hi @Niels1

Hope this article might be helpful to you.

cheers :smiley:

Happy learning :smiley:

2 Likes

Thank you for your response. However, this is not what I’m searching for. I want to have something like this (imagine this is an excel file with 1 column called “emails”):
emails
email1.eml as string
email2.eml as string
email3.eml as string

So I want to have the output of the “Save Mail Message” activity, but I want to save it as a string, and moreover want to save it for every email. The problem with this activity is that you only do this for 1 specific mail, so if you use a “for each” activity" around this, it simply overwrites the file every time a new email is saved.

1 Like

You can count the total of your csv row and if you want to insert data just pass the count plus 1 so that you will not overwrite the previous value @Niels1

cheers :smiley:

Happy learning :smiley:

2 Likes

Ok so how can I do this concretely? Currently I do this:

  1. First, I use the “Get IMAP Mail Messages” activity to read in my mails. I save the output of this activity in a variable called “emails”.
  2. I use a “Build DataTable” activity to create a data table in which I will write the .eml content of every email.
  3. I use a “For Each” activity to loop over every email in the “emails” variable created in step 1.
  4. I use a “Add Data Row” activity in this loop, because I want to add the .eml content of each mail as a new row in the DataTable variable. However, I have no idea on how to get the .eml content of a mail, convert it to a string and add it as a row in my data table.
1 Like

Hi @Niels1

I already share to you the article how you can save the email sa eml file and save anywhere you want and do your desire thing.

cheers :smiley:

Happy learning :smiley:

2 Likes

Yes I understand how I can save an email as an .eml file. But this activity only allows me to provide a file path. I don’t want to save it to a file, I want to save it as a row in a data table, and moreover, I want to do this for every email.

1 Like

Then after you save it to a row you want to save it to csv file or excel file am i correct ?
@Niels1

2 Likes

I figured it out. What I do is, for every email (which is a MailMessage object), I save it to a txt file using the “Save Mail Message” activity, and then use the “Read Text File” activity to read the content of that file again and save it as a String variable. Then, I can add it to the DataTable using the “Add Data Row” activity (with ArrayRow = {this String variable}).

2 Likes

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.