Get outlook mail message error

hello,
i have the error below of the activity get outlook mail messages:
Get Outlook Mail Messages: Cannot parse condition. Error at “@SQL=((urn:schemas:httpmail:subject LIKE…”.
this error appear when the subject of the email contains the caracters( ’ or : ) , ifnot the activity works fine,
how can i fix this error and getting the email even when the subject contain these caracters?any suggestion?

the filter is as below:
“@SQL=urn:schemas:httpmail:subject LIKE '%”+MailSubject+"%’"

It is because both of those special characters will break your SQL statement. You will need to add a delimiter before them (most likely a backslash ie "\"). One way to do this is to replace the special characters inside the “MailSubject” string just before the SQL call. For example:

assign:
MailSubject = MailSubject.Replace(":","\:")
assign:
MailSubject = MailSubject.Replace("'","\'")

you will need to do this for each special character that causes an error in your string.

1 Like

i have try this solution but not working , i have the error:
Get Outlook Mail Messages: Cannot parse condition. Error at “@SQL=((urn:schemas:httpmail:subject LIKE…”.

I’m a little bit rusty on my SQL escape characters, through from a little searching it looks like you may need to adjust the number of quotations (not sure if single or double). I do remember when working with variables in mySQL it could be a bit difficult to get them recognized completely.

One thing I would try and do if you have access to it, it try running one of your errored queries inside of whatever database you are running directly and see what type of error it throws (instead of using a variable, for now replace “mailsubject” with a string value that is throwing an error). Solving this directly in a SQL editor and query runner might be easier than in UiPath.

If you don’t have access to that environment then try and make a short test program in UiPath that does a similar thing (replace the variable with the static string that is throwing errors) and from there try to fix it and see if it throws the same error codes.