How could send outlook activity send email to myself?

I could use send outlook mail activity to email recipients.

My query is how could I send email to myself without hardcoding my email address. Is there a variable in UIPath to determine the email address of the person running the robot since outlook is already integrated with the desktop mail. Thanks !

Hi @Kindergarden,

Please use this code below:

System.DirectoryServices.AccountManagement.UserPrincipal.Current.EmailAddress

Note that: you need to import System.DirectoryServices.AccountManagement. Please add the below line in your xaml file.

System.DirectoryServices.AccountManagement

2 Likes

Hi @Sasi.lalo

Just to clarify, I am to add System.DirectoryServices.AccountManagement.UserPrincipal.Current.EmailAddress in the “To” in send outlook mail activity ?

Also, where should I add the below line into my xaml ? Thanks!
System.DirectoryServices.AccountManagement

@Kindergarden

Yes before doing this you should include the package in assembly reference of your XAML file.

To include “System.DirectoryServices.AccountManagement” in your xaml file , do the following.

  1. Open your xaml in notepad, to edit the xaml data.
  2. Include the package as assemble reference.
    <AssemblyReference>System.DirectoryServices.AccountManagement</AssemblyReference>

Save your change. Careful with the update , wrong update might corrupt your file.

Screenshot for reference

image

2 Likes

Yeah got it. Thanks @Sasi.lalo and @ranjith !

2 Likes

Hi,

Also, can advise if I could pass a variable into the filter option of the get outlook mail activity. What is working now is hardcoded below. Thanks.

“@SQL=” + “”"" + “urn:schemas:httpmail:subject” + “”"" + " like ‘%hello world%’"

@Kindergarden

Yes you can pass variable here.

“@SQL=” + “”"" + “urn:schemas:httpmail:subject” + “”"" + " like ‘%"+variableName.Tostring+"%’"

For subject you can try below expression also in Filter property.

"[Subject] = ‘The subject you want to search’ "

1 Like

Thanks. I tried to change it to filtering body of a email message to look for a certain text - which is actually email. But stranglly when I run it returns 0 count even when I message box out the reading of the excel input for the variable is correct.

Just checking if the filter I am using in get outlook message is correct below ?
“@SQL=urn:schemas:httpmail:body LIKE '%” + row.Item(1).ToString + “%’”

survey-reminder.xlsx (9.8 KB) survey-reminder-excelfirst.xaml (14.5 KB)

I have atatched the updsated verison of the program. When run against the excel input, it is reading the variable correctly. But filter retrurns 0 count.

Hi @lakshman

Could u advise if my usage is correct for searching body. i got zero count despite a match. Thanks

Buddy @Kindergarden

Try this buddy
"[Subject] = ‘[The subject you want to search]’ "

Thanks @Palaniyappan

Can you advise on the syntax if I wanna filter say, subject and body, something like

“@SQL=urn:schemas:httpmail:body LIKE '%” + row.Item(1).ToString + “%’” AND urn:schemas:httpmail:subject LIKE '%” + row.Item(2).ToString + “%’” ?

Thanks.

1 Like

Did that work buddy
@Kindergarden
Cheers

Thanks @Palaniyappan. It works. Appreciate!

1 Like

Fantastic buddy
cheers
@Kindergarden

1 Like