Writing data into excel from List<mailmessage>

Hi,

I am trying to automate a flow where I have to read mail message from outlook and write it in excel. Tried for each ad was able to write in excel, but every time the latest message is only written to excel file.

How to read from List and write in excel row wise?

1 Like

Fine
welcome to uipath community
hope these steps would help you resolve this
–use a get outlook mail activity and get the output with a variable of type list(of maimessages) named list_mails
–now use a build datatable activity and create a datatable with columns (with two columnns like mail_Subject and mail_Body )we want where we want to enter the mail message as a string and get the output with a variable of type datatable named Finaldt
–now use a for each loop and pass the above variable as input and change the type argument as System.Net.Mail.Mailmessage
–inside the loop use a activity called ADD DATA ROW activity and mention the datatable as Finaldt and in the arrayrow property mention like this {item.Subject.ToString,item.Body.ToString}
and type argument as string

–this will add the data of each mail to the datatable row by row

–now next to this for each loop use a write range activity from workbook activities and mention the filepath of workbook and sheetname on where to write and range as “” and datatable as Finaldt. Make sure that the Add Headers property is enabled in the property panel of write range activity

hope this would help you
Cheers @Lipa

@Palaniyappan

Thanks for the warm welcome :slight_smile:

I have tried to do as per the steps you gave but its failing because of the below error.

Waiting for your reply…

1 Like

In for each looo pass the output variable of Get outlook mail activity and not the datatable variable

Cheers @Lipa

Looks like I am stuck in every step as a beginner :frowning:
Anything on this…

1 Like

No worries
Mention like this
{item.Subject.ToString}
Make sure that you have only one column in the datatable
Cheers @Lipa

is it working now
Cheers @Lipa

Yay!!! It worked…just missed the curly bracket :upside_down_face:

Thanks a ton…for your quick reply… :slight_smile:

1 Like

fantastic
Cheers @Lipa

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