I’ve an RPA process in production that sends a message to multiple recipients (email addresses) at once. The shared mailbox that used to send the email out has the permission to send to a maximum of 1000 recipients per message. Now the list is growing greater than 1000 and causing a problem (failing to send). So, I have planned to split the list of mails into two batches (first batch and second batch).
I am using DataRow as a transaction item in Reframework. I want my process to send email two times (first the first batch email, second the second batch email), meaning two transactions. I am stuck here and not sure what should be the next step. Do I have to create another data table that considers DT_FirstBatch and DT_SecondBatch as first and second row?
After you get the datatable the below code splits the data to your requirement then send mail
1.DT_Emails=DT.DefaultView.ToTable(False,"Email Address") 'Replace your column name
2.List_EmailsDT=DT_Emails.AsEnumerable.Chunk(2).Select(Function(a) a.copytodatatable).tolist 'Replace **2** with your required rows i.e.,1000
Thank you for taking the time to look into this.
I’ve a couple of follow up questions with your suggestion.
I see the following error in the values of list of data table expression (DT_Emails.AsEnumerable.Chunk(3).Select(Function(a) a.copytodatatable).tolist)
Here is the error: ‘Chunk’ is not a member of ‘System.Data.Enumerable Row collection (of System.data.DataRow)’
In the above expression what does ‘Chunk(3)’ entails?
When using Reframework and DataRow transaction items, which data table am I going to use for the process two send row by row (two transactions) for the two email batches?
Please let me know if you’d need more information.
Hi @ppr
Thank you for clarifying that the issue is compatibility related. Also, appreciate for sharing the articles. Got it!
I’ll come to next question but for now let me ask this,
How do you re-write the above expression (DT_Emails.AsEnumerable.Chunk(3).Select(Function(a) a.copytodatatable).tolist) using Skip/Take. I am a little bit confused.
Just an update: I was able to write expression for Table list for skip/take scanario.
(Enumerable.Range(0, NoOfSegments).Select(Function(x)DT_Emails.AsEnumerable.Skip(x * SegmentSize).Take(SegmentSize).CopyToDataTable).ToList())
Now my next question: How can I send the message for two email batches in Reframework? I want to envision, how that portion works.