qwerty1
February 19, 2020, 12:40pm
1
Hello,
We have a new process which queries the database for orders relating to clients and customers. Bulk e-mails are required to be sent at the start of the week, with orders that have been placed up to 6 days before.
The database results look like below:
OrderNumber | DeliveryDate | contactEmailAddress
123 12/02/2020 test1@test.com
456 24/02/2020 test2@test.com
789 28/02/2020 test1@test.com
1011 01/03/2020 test2@test.com
i’m trying to somehow group & split the results of the datatable by e-mail address, so that the the order details are sent in bulk to each contactEmailAddress (rather than sending an e-mail for each order).
For example:
To: test1@test.com
From: Bot@robot.com
Your recent orders are as follows:
OrderNumber | DeliveryDate |
123 12/02/2020
789 28/02/2020
To: test2@test.com
From: Bot@robot.com
Your recent orders are as follows:
OrderNumber | DeliveryDate |
456 24/02/2020
1011 01/03/2020
I cannot get me head around how group the results for each unique e-mail address & somehow dynamically create a datatable to hold the results (for me to use in the body of an e-mail).
Any suggestions?
Thanks in advance!
karthick
(Karthick)
February 19, 2020, 3:28pm
2
Filter based on the mail id and store it in separate datatable.
Then send mail to respective mail with all correspoding data
Sample :-
(from line in dt.select where line.contactEmailAddress.equals(“test1@test.com ”) select line)
This will return rows with test1@test.com .
After u extract for all the mail IDs.
U can loop and send mail to respective mails with corresponding data
qwerty1
February 19, 2020, 3:53pm
3
Hi,
Thanks for your reply @karthick .
Could you provide some more info around this solution?
I can’t seem to picture it in my head…
Thanks
qwerty1
February 21, 2020, 10:48am
4
Would you be able so provide a test file for me to work with?
I’d really appreciate it!
qwerty1
February 21, 2020, 1:44pm
5
@arivu96 apologies, but do you have any ideas for this?
arivu96
(Arivazhagan A)
February 21, 2020, 4:01pm
6
Hi @qwerty1 ,
Get distinct of email first.
Then do for each in the loop you filter the email from the main table.
Regards,
Arivu
arivu96
(Arivazhagan A)
February 21, 2020, 4:09pm
7
1st step to filter the distinct email
DataTable dtdistinct=DataTableMain.DefaultView.ToTable(true,"contactEmailAddress")
2.use for each of dtdistinct table
Inside loop again filter to get the all the values based on distinct mail.
DataTable dtdistinctmail=DataTableMain.Select("contactEmailAddress='"+row("contactEmailAddress").ToString+"'").CopyToDataTable()
Regards,
Arivu
1 Like
qwerty1
February 24, 2020, 9:30am
8
Fantastic!
Thanks @arivu96 very much appreciated!
system
(system)
Closed
February 27, 2020, 9:30am
9
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.