Get outlook email address dynamically

Hi Friends,
I am executing bot on different user’s machine and at the end of execution bot needs to send email to respective business user.

Suppose i am executing bot then bot should send email to me only.
if another user will execute the bot then bot should send email to him/her.

so here how we can take outlook email address dynamically so that i can pass it in send outlook activity.

Regards,

you can use system.Environment.UserName to get the UserName and system.Environment.UserDomainName to get the DomainName.

Hey @Rup_1

Another option here.

You could also use:
system.Environment.UserName + “@Yourcompanydomain

Assuming your colleague was in the same company.

Hey Steven_Mckeering

Thanks for your input.

Just have a small doubt - if my outlook email address is rupesh.kandhare@mycompany.com then how we can fetch rupesh.kandhare@mycompany.com from outlook ?

Thanks,
Rupesh

Hey @Rup_1

If setup in Azure AD properly then they should be able to email: system.Environment.UserName + “@Yourcompanydomain.com

I have another option for you :slight_smile:

On another note I have made a workflow to collect the current user’s email. There are limitations, though must be a minimum of 1 email in the inbox AND that email must be addressed to them directly (and not part of an email group).

Download this Demo Workflow:
Get Email Address of Current User.xaml (10.0 KB)

Step 1: Collect Outlook Mail
Step 2: Insert For Each
Step 3: Insert Write line "item.TO.tostring
Step 4: Use this Regex pattern (preview it here)with an Assign activity to extract the email address. Like This:

Left Assign:
CurrentUserEmail (string variable)

Right Assign
system.text.RegularExpressions.Regex.Match(item.To.tostring,“(?<=<).*@[^>]+”).ToString

Step 5: Insert Write line with ‘CurrentUserEmail’.
Step 6: Validate results.

There are definitely more efficient options out there but hopefully this helps you with your needs.

Happy Automation :blush:

Cheers

Steve

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