Get outlook message and filter body to send email when condition met

Hi,

I have a program that sends out reminder based on an input file. Attached working version.

However, I would like to improve it by using get outlook mail to filer the email with “subject” and a “body”. The body has a text label “email”, not the From field. Then compare the excel email column with the mail messages and send a reminder.

Any expert can help me add in the codes? Thanks !

survey-reminder.xaml (7.5 KB)
survey-reminder.xlsx (9.8 KB)

Hi,

you have to use Get Outlook Mail Messages or Get Exchange Mail Messages activity. Both as output returns list of mail messages. You can iterate through this list using for each, please use System.Net.Mail.MailMessage as TypeArgument for for each. You can view body using it’s property ‘.Body’, specified text in body can be found using regex (import System.Text.RegularExpressions namespace). Example: Sequence2.xaml (8.1 KB)

Thanks @lakshman and @Palaniyappan for the tremendous help just when I need it.

I will test out the shared mailbox and update so that the rest could benefit.

Could you also check out my post as iI need a working sample as I am cluelss realy. Newbie here but need to dive in.

1 Like

Thanks @p0tfur. I am not familiar with regex. Also, I am not looking for a text per se. I could use filter to do that like subject which I have done.

What I need is in the mail, there would be a text called Email. U see, it’s a form. So, I need to check for the value next to the Email label. I am not sure whether this is possible.

Then, with the email from the body, not From field, compare with excel column for email and send a mail to those who have not submitted their forms.

Buddy may i know what that email label in the body actually has buddy @Kindergarden

Hi @Palaniyappan

It’s an email that has text as attached. And the body text has Email label and the value contains and email address. This is so we could use it to compare with the excel input. Then for those who have yet to submit the form, to email reminder. Thanks !

1 Like

here is your xaml buddy @Kindergarden
survey.zip (10.3 KB)

Kindly check with this and let know buddy
Cheers

Thanks @Palaniyappan. You are fast ! I will test it out. To send reminder, the send email should be in the else right I suppose as I try to figure your codes.

Sure buddy @Kindergarden
kindly try this and let know whether that works or not
Cheers @Kindergarden

Hi @Palaniyappan,

The condition item.Body.ToString.Contains(row(1).ToString) will meet when body email matches excel input email column.

So if i wanna send reminder to those who have not submitted, and therefore no email, then the send email activity should be placed in the ELSE cndition then?

1 Like

yes buddy exactly @Kindergarden

did that work for one which matches
Cheers @Kindergarden

Haha buddy. You are fast ! I am still working out the shared mailbox. Will get back. I am a newbie :smile:

1 Like

Hi @Palaniyappan

It is not showing the expected results. Do you think we should use “not contain” instead of putting the send email activity in the ELSE condition.

Or should the excel be read first then loop thru the email messages ? Becos what we have now is for every email it will loop thru the excel again. So, the same person gets sent more than once for reminder. Thanks !

HI,

It is not showing the outcome. Sorry, the requirement is
(i) The excel file has a list of email.
(ii) And it is used to check against email messages for the body that contains the email address.
(iii) If there is no match, then the person in excel email address will be sent a reminder.

I have attached the pictures that show existing codes where it is reading email message; and for every message loop thru the excel to find a matching email address instead. Thanks.

I changed the logic to read excel for email. Then filter body for email address (excel input) using the get outlook message below
“@SQL=urn:schemas:httpmail:body LIKE '%” + row.Item(1).ToString + “%’”

But stranglly when I run it returns 0 count even when I message box out the reading of the excel input for the variable is correct. And I have email message whose body contains the emailaddress.

Does anyone know if the filter statement works ? I have used it for filtering subject without problem. Thanks.

survey-reminder.xlsx (9.8 KB) survey-reminder-excelfirst.xaml (14.5 KB)