Hi everyone, I would like help/guidance in creating a sequence for collating all the email addresses from my Outlook inbox and compiling them in a new Excel file.
Thank you for your help!
Hi everyone, I would like help/guidance in creating a sequence for collating all the email addresses from my Outlook inbox and compiling them in a new Excel file.
Thank you for your help!
LLM helped me to write this but it’s validated by me.
To collate all email addresses from your Outlook inbox and compile them into an Excel file using UiPath Studio, follow this step-by-step guide:
Prerequisites
Make sure you have the UiPath.Mail.Activities package installed.
Ensure that you have access to Outlook and it’s configured on your system.
Steps
mailMessages (Type: List) — Stores the list of emails retrieved from Outlook.
emailAddresses (Type: List) — Stores the extracted email addresses.
outputDataTable (Type: DataTable) — Stores the email addresses for Excel output.
Use the Get Outlook Mail Messages activity:
MailFolder: “Inbox”
Top: Specify the number of emails to retrieve (or leave it empty for all emails).
Output: mailMessages
Use the Build Data Table activity:
Add a single column named “Email Address” of type String.
Assign the output to outputDataTable.
Use a For Each activity to loop through mailMessages:
Type Argument: System.Net.Mail.MailMessage
Inside the loop, add the following steps:
4.1. Get Sender Email Address:
Use an Assign activity:
To: senderEmail
Value: item.From.Address
Use an If activity to check if the email is not already in the list:
Condition: Not emailAddresses.Contains(senderEmail)
If True, use Add to Collection to add senderEmail to emailAddresses.
4.2. Get Email Addresses from Recipients:
Loop through item.To and item.CC using nested For Each activities:
For each recipient, use an Assign activity:
To: recipientEmail
Value: recipient.Address
Check if recipientEmail is not already in the list and add it using Add to Collection.
Use another For Each activity to loop through emailAddresses:
Inside the loop, use the Add Data Row activity:
ArrayRow: { email }
DataTable: outputDataTable
Use the Write Range activity (from Excel activities):
DataTable: outputDataTable
File Path: Specify the path where you want to save the Excel file.
Sheet Name: “EmailAddresses”
Add Headers: Check this option.
Complete Workflow Summary
Get Outlook Mail Messages → Retrieve emails.
Build Data Table → Initialize the DataTable.
For Each (mailMessages) → Extract email addresses:
Get sender, recipients, and CC addresses.
For Each (emailAddresses) → Populate the DataTable.
Write Range → Export to Excel.
This workflow will help you create an Excel file with all unique email addresses from your Outlook inbox. If you encounter any issues or need more specific help, let me know!
Use get mail or get outlook any mail activity
Now you have list of mails with you
You can use generate datatable activity and give string as String.Join(Environment.NewLine,mails.Select(function(x) x.FromEmail.Address))
and select cav parsing…it would give you a datatable
Now use write range to write datatable to excel
Function remains same but this prt x.FromEmail.Address
might differ based on what email activity you use…adjust accordingly
Cheers
Hi Thank you for the guide but I have a few queries.
Firstly,
“mailMessages (Type: List) — Stores the list of emails retrieved from Outlook.
emailAddresses (Type: List) — Stores the extracted email addresses.”
I cant seem to find the Type: List.
Secondly,
My Get Outlook Mail Message Activity does not work properly and after i keyed in Output: mailMessages, there is an error.
Thanks!
I did this sequence. It seems correct but my Excel sheet did not display any email address. It is just a blank sheet:
This is the excel sheet after the bot runs: