Based on variable to add email address in outlook

Hi All

anyone can help or provide a better solution to add the correct email address in send outlook activity? thank you in advance.

I have a set of variables in a data table which is dynamic (e.g. it could be b,c or a,d) and whenever sending of email is required, the flow will go to the excel sheet to read the email address based on the Alias name in the excel and placed the email address in the send outlook activity and send out the email to the correct recipient.

image

referring to the emaill address matrix screenshot

Hi @Waka

Assigning the mail addresses to an string variable and passing the same to the mail sending activity is correct. Since you are getting the data from the excel & the email list will be updated dynamically based on the alias name, you can use this approach.

→ Convert the email data table into a dictionary. Use this query in the assign activity to do so:

yourDictionary = emailDataTable.AsEnumerable().ToDictionary(Function(row) row("Alias name").ToString(), Function(row) row("email address").ToString())

→ Now you can get the email address from the dictionary using the alias name like this:

email1 = yourDictionary(“aliasName”)

→ Once you have the name, build an emailList string and pass the same to email sending activity.

Hope this helps,
Best Regards.

Hi Arjun

as I don’t have much programming knowledge about the syntax/logic introduce to me.

the “emailListing” in my test case was declared as string and not dictionary thus may i know how to go about changing it to dictionary?

besides, the email1, email2 are also dynamic because the number of email address to be included in the sending list could be 1 or 5 such as depending on the data table Alias name passed over to this flow.

example. if the data table passed the alias names consist of a,b,e then the email address will be email addresses for a,b,e and subsequently when the work flor next run the data table alias names could be b,c,e or a,d,b then the email addresses will be added in the email addresses.

does this logic works this way too ?

@Waka

Please find the attached workflow where the above logic has been implemented, and please let us know if you find any complications in understanding the same:

Here, you can see how the data table has been converted into a dictionary & the email addresses has been taken dynamically into the emailListing using the dictionary’s key-value property -

DynamicEmailAddressProcess.zip (147.4 KB)

Hope this helps,
Best Regards.

@arjunshenoy

thank you for the solution

however, for this part “yourDictionary(“a”).ToString+”,“+yourDictionary(“c”).ToString+yourDictionary(“e”).ToString” were hard coded with “a”,“c”,“e” to retrieve the email address but i have a datatable that containing “a c e” and how can i break this datatable values into the assign activity ?

@Waka

If you are getting the a, c, e like data from a data table, you can use a For Each loop over that data table and inside the loop, you can build this string like this:

emailList = emailList+","+yourDictionary(currentRow("Alias Name").ToString).ToString

This will build a string like yourDictionary(“a”).ToString+”,“+yourDictionary(“c”).ToString+yourDictionary(“e”).ToString only, but with dynamic Alias Name from the data table.

Hope this helps,
Best Regards.

@arjunshenoy

the solution provided can work but when i use it at my file and i got error message below

The data table you are using is read range from sheet 1 but my file datatable is reading range from sheet 2

so when the process passed the data table read from sheet 2 Col “Names” then it would refer sheet 1 Col Alias Name to get the email address then send out.

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