Get outlook mail message activity not returning value

I am using get outlook mail message activity. In that i have added filter like : “@SQL=urn:schemas:httpmail:subject LIKE '%” + Subject + “%’ AND urn:schemas:httpmail:fromemail = '” + Sender_ID + “’ AND urn:schemas:httpmail:datereceived >= '” + Search_Date.ToString + “'”

Subject and Sender_ID are variables. In this when the ID is test@test.comtest@test.com the query is returning correctly. But when the id is “test” test@test.com it is not able to return any value.
Value here i mean identifying the mail.

only difference i see is in the name of the sender in the first case where it is working fine it is having name as “test@test.com” and in the second case name is without @.

how do we handle this?

Hi Veeresh,
Can you try below code and check,
“@SQL=” & “urn:schemas:httpmail:subject LIKE '%” & Subject & "%’ " & “AND urn:schemas:httpmail:from LIKE '%” & Sender_ID & "%’ " & “AND urn:schemas:httpmail:datereceived >= '” & Search_Date.ToString(“g”) & “'”

Hope it works!

I used the code: “@SQL= urn:schemas:httpmail:subject Like '%” & Subject & “%’ " & " AND urn:schemas:httpmail:frommail LIKE '%” & Sender_ID & “%’ " & " AND urn:schemas:httpmail:datereceived >= '” & Search_Date.ToString & “'”

It is still not working.

Hii @veeresh.p Here one approach is to remove the sender filter from the @SQL query and filter in UiPath after retrieval by checking mail.SenderEmailAddress or SenderEmailType = SMTP, which works consistently and

a second approach is to extend the SQL filter to include the display name by combining

urn:schemas:httpmail:fromemail and urn:schemas:httpmail:fromname

in an OR condition so either the email address or the sender name is matched

Cheers

Remove the sender condition from the @SQL filter and retrieve emails using subject/date only.Then, in UiPath, filter using mail.SenderEmailAddress or check SenderEmailType = "SMTP".
This works consistently across Exchange and external senders.

Alternately you can Extend the @SQL filter to include both sender email and display name by using an OR condition with:
urn:schemas:httpmail:fromemail and urn:schemas:httpmail:fromname.

Always keep Outlook SQL filters simple and perform complex sender matching in the workflow logic for better stability.

Hi @veeresh.p

This happens because fromemail matches the actual email address, not the display name.
When the sender name is shown as “test” instead of “[test@test.com]”, the filter fails.

To handle this, avoid strict equality on fromemail. Use LIKE instead, for example:

@SQL=urn:schemas:httpmail:fromemail LIKE ‘%[test@test.com%]’

Or remove the fromemail filter and validate the sender email in the workflow after fetching the mails. This is a known Outlook filter behavior.

Thank you all for your input. I removed Sender_ID and processed.
i had a scenario where we have Sender_ID. so i used if..if sender_ID = “” then SQL is
“@SQL= urn:schemas:httpmail:subject Like '%” & Subject & “%’ " & " AND urn:schemas:httpmail:datereceived >= ‘” & Search_Date.ToString & “’”
Else
“@SQL= urn:schemas:httpmail:subject Like '%” & Subject & “%’ " & " AND urn:schemas:httpmail:frommail LIKE '%” & Sender_ID & “%’ " & " AND urn:schemas:httpmail:datereceived >= ‘” & Search_Date.ToString & “’”