How to filter mails by source id in get outlook mail message?

Hi Everyone,

I would like to ask that how do we apply filter by using source email id.
let me explain the scenario of my task-

  1. I have automated a process in which bot reads the mail based on subject lines and then it compares the same mail to an excel sheet’s subject lines if both subject lines are same then it raises a ticket against the same mail.

  2. I now want that after comparing with subject lines it also checks source Id and if mail’s source Id and excel id against subject lines are same then it should go for next process.

Regards,
TIN RPA

@TIN_RPA

Which email actiity are you using?

accordingly we can suggest the filter epression

cheers

Hi @Anil_G,

I am using get outlook mail messages activity.

Regards,
TIN RPA

@TIN_RPA

here are all filters

one you need

cheers

Hi @TIN_RPA

To get the source email ID you can use

You can assign it to a variable & put it in if condition to match with excel email id

currentItem.Sender or currentItem.SenderEmailAddress

Hope this helps :slight_smile:

Hi @AJ_Ask,

I have already filtered the email by subject lines and it is working and now want to check with it sender email address as well.
Just help me with sender email address, means how to compare with these two at the same time. as soon as bot get read the mail then it checks the mail with excel sheet data and if any subject matches then it should check sender email id (outlook mail sender and excel sender against the same subject).
so I am able to compare it by subject and now need your help on sender mail address comparison.

Regards,
TIN RPA

Hi @TIN_RPA

Read your excel sheet with subject & Email Address information & save it in Datatable


After reading the mails by using the Get outlook mail messages. Loop over it by using For each inside that put another for each row in data table which will iterate through our excel values data table. Put a if condition like below to check both the subject & Email address comparison.

CurrentRow(“Subject”).ToString = “Test” AND CurrentRow(“Email”).ToString = currentItem.SenderEmailAddress.ToString

For your ref:
Email.zip (10.5 KB)

Hope this helps :slight_smile:

Hi @AJ_Ask,

Thank you for your reply. let me mention the conditions which I have put for reading outlook subject lines and comparing it with excel sheet subject lines.

  1. firstly, I have used this -
    image

  2. after that used this for comparing-
    image

So here what is happening, bot is able to get the mail and then it compares the mail’s subject with excel subject and if it gets matched then it logs a ticket for this.

So my concern is whenever it gets an email then it should also check the excel sheet sender email address along subject and if both (mail’s subject sender address and excel sender address) are same then it needs to log the ticket.

I want to add-on in above mentioned logic for sender email address as I have different sender addresses against mails.

Could you please check it and help me out on this.

Thank you very much in anticipation !!

Regards,
TIN RPA

Your condition is correct for checking subject.

Put similar condition for checking the email address & join with AND function in If statement. If both conditions are correct it will go ahead or it will go in else.

Hi @AJ_Ask,
I have assigned that from id value as you can see below SS-

image

I have done what you suggested however I would like to ask about If condition, how to write it for If condition -

I would appreciate your prompt reply here !!

Regards,
TIN RPA

Hi @TIN_RPA

Condition will look like this instead of “Test” use the subject & Email Id respectively that you will fetch from get outlook mail message.

Arr_SubjectLines.Any(Function(item) item.Trim().Contains(“Test”)) And Arr_FromID.Any(Function(item) item.Trim().Contains(“Test”))

Hope this helps :slight_smile:

This code is just the simpler version of what you are doing with the arrays.
You can use this also.

Hi @AJ_Ask,

Thank you very much !
I have used the same condition for sender email address which I have used for subject lines and It worked.

Regards,
TIN RPA

Hi @TIN_RPA

Awesome. :slight_smile: Mark one of my reply as solution so that it can help others also.

Cheers.

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