Can I send Outlook e-mail based on excel data condition?

Hello, all

I’d like to send e-mail if specific column condition is ‘False’
Can I achieve it with Activities function?

  1. Select only ‘False’ contents row (Feedback column)
  2. Including excel information to Outlook body , header… etc dynamically

image

Thank you~

@Dorothy_lee - Based on condition, we can able to write the flow.

Please follow the below steps.

  1. Call read range activity from workbook and create output variable “DT”.
  2. Call the For each row activity next to read range activities and give input value “DT” variable.
  3. Third step call Assign activity inside of the body, then create new Variable like “Feedback” and Value “row(3).tostring”.
  4. Here you can use If condition activity next to assign activity and condition is "Feedback = “False” " then, inside of the body you can write the condition in then section. what ever you want.

I hope it will give some idea, to create a remaining steps. If you need more clarity please let me know.

Happy Learning :slightly_smiling_face:

1 Like

@Dorothy_lee - Another option would be filter the data first (this will avoid the if condition) and then read filtered data in the foreach loop for sending the email…

DtFiltered = (From r In Dtout.AsEnumerable
Where r("Feedback").toString.Contains("FALSE")
Select r).CopyToDataTable

Here dtfilterted is of variable Datatable.

For Dynamic body, Please try like this…(Copy paste the right hand side value to your body)

Make sure to check - isBodyHtml Checkbox in the property…

Hope this helps…

3 Likes

@prasath17 Hello ! Thank you for suggesting great option!
I have inquiry about DtFiltered variable. Should I have to assign value like below? Am I correctly set…? How is it applied to datatable?
I’m currently using ‘test_dt2’ as output result.


@Dorothy_lee - Yes, this seems to be correct. if you want to verify the result before proceeding to the for each, use “Output Datatable activity” and write the result to String variable and print the variable.

Note: Please print the test_dt2 before applying dtfiltered (using the same process explained above)

If dtfiltered is fetcing all the correct “FALSE” items then you are good to proceed.

@prasath17 Faced below error message. Did I set something wrongly?


“message”: “Assign: The source contains no DataRows.”,
“level”: “Error”,

@Dorothy_lee - I guess its test_dt…not test_dt2…

Whatever datatable you previous use and which has datarows that is the one you have to give it in dtfiltered assign activity.

Now I’m not facing the no Datarow issue once I changed from FALSE to False but still it’s unable to filter only False when I print out with Output Datatable Activity.
It’s printing out Ture value as well.
image
Really not sure which part is incorrect… Humm

dt = dt1.AsEnumerable.Where(Function (x)x(“Feedback”).ToString = “False”).CopyToDataTable

1 Like

@prasath17 By the way, I’m able to send e-mail with variable value based on your guide! Thank you.
Is there any way that For each row is broken if the excel data is null?
I’d like to set if row data is null, stop sending e-mail.
image

1 Like

@Dorothy_lee - you have to add another and condition on the dtfiletred itself to control the null datarows…

update:

 DtFiltered = (From r In Dtout.AsEnumerable
Where r("Feedback").toString.Contains("FALSE") and (not r("Feeback") is Nothing orelse 
Not String.IsNullOrEmpty(r("Feeback").ToString))
Select r).CopyToDataTable
1 Like

@prasath17 Hello,
Actually, DtFiltered assign function is not working for filtering “False”. So, I’ve tried with Macro.
Now I’m trying to use DtFiltered assign activity again for making only exception of Null. Below code is correct…?
(From r In test_dt.AsEnumerable
Where r(“Feeback”) Is Nothing OrElse
Not String.IsNullOrEmpty(r(“Feeback”).ToString))

@Dorothy_lee - Could you please share your sample excel sheet (After removing the all the sensitive data)??

test_e-mail.xlsx (8.1 KB)

Here it is! Thank you~!

1 Like

@Dorothy_lee - I see this has only FALSE…Could you please share the one with NULL and True Conditions ?? So that I can filter for NULL and FALSE in one shot…

test2.xlsx (8.8 KB) P00433_E-Mail_FeedBack - Copy.zip (20.5 KB)
Oh Thank you. ! I attached again

@Dorothy_lee - Here is my xaml

dtfiltered = (From r In Dt.AsEnumerable
Where r("Feedback").toString.ToUpper.Contains("FALSE") And (Not r("Feedback") Is 
Nothing OrElse 
Not String.IsNullOrEmpty(r("Feedback").ToString))
Select r).CopyToDataTable

Please See the output below…

Hope this helps…

1 Like

@prasath17 Thank you so much!
It’s perfectly working now… !

1 Like

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