Outlook Send Emails

Type of reusable component: Outlook send emails

Question: How can I send multiple emails from outlook

Current Behavior: I am looping through the excel file to see who have the score less than 40 and in column 11 I have the user’s email, and in column 12 I have manager’s email. Right now after each loop, outlook sends emails.

Expected Behavior:I want to send one final email to all user’s in column 11 and column 12. How do I do it? Please help

Studio/Robot/Orchestrator Version: Studio 2019 version 5.0

I’m not sure if I Understood your point but you can join Recipients’ email addresses and pass it to send email activity, so it will send One email to all.

Hi @Vidya_Lingappa
Kindly follow the below steps that could help you resolve your issue

  1. use excel application scope and pass the file path of your excel
  2. use read range activity and get the output of variable type datatable and name it out_dt
  3. use a for each row loop and pass the above variable as input
  4. inside the for each row loop use a if condition and mention the condition as
    Convert.ToInt32( row(“Yourscorecolumnname”).ToString)<40
    if this condition gets passed it will go to THEN part of if condition
    inside the THEN part use a assign activities like this
    out_mailid = row(“Column11”).ToString+“;”+row(“Column12”).ToString

where out_mailid is variables of type string
5.while still being inside the for each row loop, use send outlook mail activity and mention the variable in TO property and mention the subject and body you want
Hope this would help you
CHeers @Vidya_Lingappa

Hey @Vidya_Lingappa

  1. Use Excel Application Scope Activity and pass the file path of your excel
  2. Use read range activity and get the output of variable type datatable and name it SampleDT
  3. Define before loop proces.
List<String> UsersList = New List(Of String);
List<String> ManagersList = New List(Of String);
  1. Use a for each row loop and pass the above SampleDT as input
  2. Convert.ToInt32( row(“Score Column”).ToString)<40
    if this condition gets passed it will go to THEN part of it.
    inside the THEN part we will add Failed user in list and Their respective manager in Manager list.

6 outside loop just use Send Mail Acitvity(outlook or else as per your needs :)) and in To
mention String.Join(“;”,Mail_ReciepientsListStr_Users.Distinct.ToArray)

and in CC Mention String.Join(“;”,Mail_ReciepientsListStr_Managers.Distinct.ToArray) managers list. :wink:

even with this way if failed users are having same manager it won’t go to same manager twice :slight_smile:

Find Below sample for your basic understanding or Reference :slight_smile:
OutlookSendEmailMultipleReciepientsSample.xaml (12.2 KB)

Cheers :slight_smile:

Regards…!!
Aksh

1 Like

Aksh, thanks so much. I will try today and let you know if I face any issues.

Aksh, You sample code is excellent. But I have a small issue. In your SampelDT table you have 2 columns: UserEmail and ManagerEmail. So where are you assigning these variables? I could not locate them in the invoke method. I am a bit confused. Because I have column(11) as UserEmail and column(12) as ManagerEmail. Please clarify.

Palani, Thank you for the explanation. I have assigned the row(“Column11”).ToString";“+row(“Column12”).ToString+”;"+"testmgr@test.com" to a mailid variable. and the system is complaining: End of Expression expected. What am I missing? Could you please advise.

we need to mentionlike this buddy
row(“Column11”).ToString+“;”+row(“Column12”).ToString+“;”+“testmgr@test.com”
just a small correction + is missing
Cheers @Vidya_Lingappa

were you able to get that now buddy @Vidya_Lingappa

Aksh, I need little bit clarification. In your SampelDT table you have 2 columns: UserEmail and ManagerEmail. So in your code where are you assigning these variables? I could not locate them in the invoke method. I am a bit confused. Because I have column(11) as UserEmail and column(12) as ManagerEmail. I am waiting for your response. Could you please clarify.

Palani, yes got it.

1 Like

Great @Vidya_Lingappa
Cheers

Note:- if you want to let me know when you have to ask something please tag me using @ with my username. so can get notifications :slight_smile:

Regards…!!
Aksh

1 Like

Thanks and it is working now. @aksh1yadav

Hi Palani, in the method proposed by you, how do I avoid duplicate emails to managers? meaning if there are 2 users reporting to same manager.
Any idea? please let me know.
Thanks,

Any how they are different users with different marks right, though the manager is same, as the users are different with different or same marks even, manager must be intimated about them individually know buddy…
So i think we dont need to find the duplicates with same manager with 2 different users
Kindly correct me if i m wrong
Cheers @Vidya_Lingappa