Hi all, I have received an email with a distribution list inside the CC field.
The distribution list is a single email, but multiple members are contained inside when you expand the list.
When i try to use UIPath to obtain the CC recipient(get outlook mail message->ListMessages(0).CC.ToString), UiPath returns a null value.
Is there any way I can obtain the distribution list email as the CC recipient?
This does not work because the email is a distribution list. It returns null as the CC recipient. I would love to send you a sample email for testing but unfortunately the email is work related, so sorry about that.
To extract all the emails Id from the distribution list you can try using shell script.
Step1- open Notepad and paste the following code and save it as .ps1 file
Note- You will get popup in run time where you have to enter your outlook Id and password
$o365cred = Get-Credential emailid@domain.com // enter your own outlook email id
$session365 = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri “https://ps.outlook.com/powershell/” -Credential $o365cred -Authentication Basic -AllowRedirection
Import-Module (Import-PSSession $session365 -AllowClobber) -Global
$DGName = “Distribution list email Id”
Get-DistributionGroupMember -Identity $DGName | Select PrimarySMTPAddress |
Export-CSV “D:\DlList.csv- File where email id are extracted” -NoTypeInformation -Encoding UTF8
Step 2- If you directly run the shell script or invoke the shell script - You may encounter error stating- "cannot be loaded because running scripts is disabled on this system. For more
information, see about_Execution_Policies "
to avoid the following error you can create a bat file to execute the shell script-
Steps for the same are as below-
Open a notepad and paste the below code and save it as .bat file
Create a new List(Of String) variable to hold the list of email addresses and use the ‘invoke method’ to add email to the list, I later changed the list to string because I needed to add it to the queue as string: