Get email recipient, sender, date, and subject line to excel log


I want to receive an email then log recipient, sender, date and subject line to an excel log.
Write line isn’t worker for email.sender.displayname.tostring


Email is my variable

That’s not working, an error on writeline


May i know what error are you getting here ?

Make sure Email variable should be of type System.Net.Mail.MailMessage

Once after getting mail lust from Get Outlook Mail activity
—now use a BUILD DATATABLE Activity and create three columns of type string named
sender, date, subject and get the output with a variable of type datatable named dt
—the use a CLEAR DATATABLE ACTIVITY and mention the variable dt
— pass the output variable to a FOR EACH activity and inside the FOR EACH activity mention the type argument as System.Net.Mail.MailMessage and inside the loop use a assign activity like this
str_sender = item.Sender.Address.ToString
And another assign activity like
str_date = item.Headers[“Date”]
And another assign activity like
str_subject = item.Subject.ToString

Now we can use ADD DATAROW ACTIVITY and mention the ArrayRow property as
{str_sender,str_date,str_subject} and in the datatable mention as dt
So that it will get added to excel as a log

—then we can use write range activity and pass the variable dt as input and ensure that add headers property is enabled

Hope this would help you
Cheers @sparkplug93

I’m getting an error in the arrayrow where it’s not the proper value types and assign date isn’t working. Thanks

1 Like

Include .ToString to that expression and try once
Cheers @sparkplug93

I’m still having trouble with arrayrow

1 Like

Fine buddy
The date variable will be like this with expression
Str_date = item.Headers(“Date”).ToString

Now we can use this in the ArrayRow
Kindly try this and let know for any queries or clarification
Cheers @sparkplug93


ArrayRow should be mentioned like this as per the process mentioned

Cheers @sparkplug93

What would my inputs for Write Range be

After running the workflow I got an error under each string sender, date, and subject

I am getting an error only under the assign variable. that it can’t be converted to string from generic value

Can I have a view in the xaml if possible
Cheers @sparkplug93

Get Emails.xaml (9.5 KB)

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