Mail Trigger based on excel department

Hello,

I have a excel file which is contain a set of data. In Column C has department name. Now i need to filter each department wise and copy that data and need to send as an excel attachment.

Note : Department May increase or decrease based on the data pulled. But i need to send the mail only for available department in the Column C.

Hey @jais1609

UniqueDept=(from dr as datarow in dt select dr.item("Department")).distinct()

For each item in UniqueDept

NewDtforDepartment=(from dr as datarow in dt where dr.item("Department") select dr).copytodatatable

Hy @jais1609,

You could try the following:

Read Excel

Use the ‘Read Range’ Activity in ‘Excel Application Scope’

Get unique Departments:
MyDTDepartments = MyDT.DefaultView.ToTable(True,“Departments”)

Loop through this data table using a ‘for each row’ activity
Create new excel files based on the filtered data

Is it clear for you?
Please let me know if you have any questions.

Regards

1 Like

Thank you Buddy. I will try this and keep you posted. :grinning:

Can you please explain the code how it will work.

UniqueDept=(from dr as datarow in dt select dr.item(“Department”)).distinct()

i am little confused on this.

Hy @jais1609,

Very glad I could help you, please like my post, it helps me.

Try it and let me know if you enconter any issues or it worked as you wanted.

Regards

1 Like

Hey @jais1609

This will pick unique references from your datatable to a generic collection.

Second line of code where we have used for each

It will filter datatable for each unique reference and copy it into a new datatable.

If you can provide a dummy excel, I ll share the screenshot for your ref.

Please see the attached dummy data. I need to filter the department. And send the data.(just like copy and paste in new excel and save the data based on department name. Kindly assist me.Department.xlsx (545.8 KB) Main.xaml (9.8 KB)

1 Like

I have Tried but it was fail.Please see the attached dummy data. I need to filter the department. And send the data.(just like copy and paste in new excel and save the data based on department name. Kindly assist meDepartment.xlsx (545.8 KB) Main.xaml (9.8 KB)

Here you go.

Sequence1.xaml (7.7 KB)

1 Like

Thank you.i have run the project that you have attached. But it was not running currently. i am getting error in write range activitie.

Note - i have updated all details in the send outlook activities.

@jais1609 What was your error message ?

it was in Write Range. Item.Tostring then i have changed to new Excel Scope and Write Range activity then it was fine. Thanks a Lot. I really Appreciate your help. :heart_eyes: :heart_eyes: :heart_eyes: :grinning: :grinning:

1 Like

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