Special characters affecting Outlook mail activities query.
Issue Description
When using special characters in an Outlook Mail activity filter, the filter may not be read properly. This can result in unexpected behavior, such as no emails being returned by the Get Mail activity or emails not being sent to the target address. Other issues may arise depending on the filter configuration.
This issue is more prominent when using JET queries rather than DASL queries. While switching to a DASL equivalent query can resolve the issue, it may be time-consuming and complex, especially for large queries.
Example Scenario
A filter in JET may look like this:
"[SenderEmailAddress]='Mike@Uipath-team.com'"
In this case, the filter may not return any emails, even though it should match emails from the given sender. The issue occurs because of how special characters like the hyphen (-) are handled in JET queries.
When the special character issue occurs, users may experience:
- No emails returned in the
Get Mailactivity despite a matching filter. - Failure to send mail to the specified target address due to improper filtering.
- Unexpected or blank results in other activities where the filter is applied.
In such cases, the results may appear as an empty list, or the mail may not be delivered to the correct recipient.
Resolution
To resolve this issue while keeping your existing query structure, you can replace the special character(s) in your query with a .NET Char instance followed by the corresponding ASCII number code.
For example, to replace the hyphen (-), whose ASCII code is 45, you would use the following structure:
"[SenderEmailAddress]='Mike@Uipath"+Chr(45)+"team.com'"
This method works because the query is treated as a string, and the special character is correctly interpreted when replaced with its ASCII code.
You can find a full list of ASCII codes online to assist with replacing other problematic characters.
DASL Query Example
For users who prefer or need to use DASL queries, the following example demonstrates how to filter based on the sender email address. DASL queries handle special characters more gracefully than JET queries:
"@SQL=""urn:schemas:httpmail:fromemail"" LIKE ''Mike@Uipath-team.com''"
Step-by-Step Guide to Implementing the Resolution
To implement this solution within UiPath Studio, follow these steps:
- Open UiPath Studio and navigate to the workflow where the
Outlook Mailactivity is used. - Identify the Activity where the filter is being applied (e.g.,
Get Mail,Send Outlook Mail, etc.). - Edit the Filter: In the properties of the activity, find the
Filterproperty where the special character issue occurs. - Apply the ASCII Replacement: Replace the problematic special character(s) by using the
.NET Charinstance and the corresponding ASCII code as shown in the examples above. For instance, replace the hyphen in"Mike@Uipath-team.com"with"Chr(45)". - Test the Workflow: Run the workflow to verify that the filter now behaves correctly and returns the expected results.
Applicable Activities
This solution applies to any of the Outlook Mail Activities that use filters, such as:
- Get Mail
- Send Outlook Mail
- Move Outlook Mail
- Reply Outlook Mail
- Forward Outlook Mail
Successful and Non-Successful Examples
Scenario 1: Non-Successful Filter (before applying the fix)
Filter query:
"[SenderEmailAddress]='Mike@Uipath-team.com'"
- Expected Behavior: This query should return emails from the sender
Mike@Uipath-team.com. - Actual Behavior: No emails are returned due to improper handling of the hyphen (
-).
Scenario 2: Successful Filter (after applying the fix)
Revised filter query:
"[SenderEmailAddress]='Mike@Uipath"+Chr(45)+"team.com'"
- Expected Behavior: The query correctly filters emails from
Mike@Uipath-team.com. - Actual Behavior: Emails from the specified sender are returned successfully.
Additional Notes
- If you are unsure of the ASCII code for a particular character, refer to an online ASCII code chart to find the corresponding number.
- The
.NET Charmethod only works for specific characters that cause issues with filtering. It is not necessary for all queries but is essential for resolving issues with special characters like-,@,+, and others.
Conclusion
This solution ensures that special characters in Outlook Mail Activity filters are correctly handled, allowing queries to execute as expected without errors or unexpected results. By replacing problematic characters with .NET Char and the appropriate ASCII code, you can ensure the stability and accuracy of your email-related workflows.