Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
RA6
Creator
Creator

Issue with tPOP

Hello guys,

I am trying to retrieve emails using tPOP with filter subject and from.

I have special characters in the email subject; Example [AAA] Test1

If i put the subject directly in the filter while escaping the characters, it works fine. I retrieve the emails correctly:

0695b00000SprVuAAJ.png

But if i put the same subject in a context variable => context.MAIL_Subject and i escape it, it does not work => NO EMAIL FOUND

context.MAIL_Subject = context.MAIL_Subject.replace("[","\\\\[").replace("]","\\\\]");

System.out.println(context.MAIL_Subject); => \\

[AAA\\] Test1

0695b00000SprYUAAZ.png

Can someone advice please?

Best regards,

RA

Labels (3)
1 Solution

Accepted Solutions
gjeremy1617088143

String str = context.MAIL_Subject.replace("[","\\[").replace("]","\\]");

context.MAIL_Subject = str;

 

cause as far as i understand :

you have "[AAA]" you want "\\[AAA\\]"

if you print "\\[AAA\\]" you'll see "\[AAA\]"

if you replace [ and ] by \\\\[ and \\\\] and print it you will see "\\[AAA\\]" on the console but the string value will be "\\\\[AAA\\\\]" and not "\\[AAA\\]"

so if you replace [ and ] by \\[ and \\] and print it you will see "\[AAA\]" in the console but the string value will be "\\[AAA\\]" like your direct input wich work.

and i check you can use directly :

context.MAIL_Subject = context.MAIL_Subject.replace("[","\\[").replace("]","\\]");

it will works too.

View solution in original post

4 Replies
gjeremy1617088143

Hi @Rohit Aftab​, you apply the replace method to the same variable you try to affect the value.

You can do something like this instead:

String str = context.MAIL_Subject.replace("[","\\\\[").replace("]","\\\\]");

context.MAIL_Subject = str;

RA6
Creator
Creator
Author

I tried the solution but it is still not working.

 

String str = context.MAIL_Subject.replace("[","\\\\[").replace("]","\\\\]");

context.MAIL_Subject = str;

 

 

Result => Still no mail found

gjeremy1617088143

String str = context.MAIL_Subject.replace("[","\\[").replace("]","\\]");

context.MAIL_Subject = str;

 

cause as far as i understand :

you have "[AAA]" you want "\\[AAA\\]"

if you print "\\[AAA\\]" you'll see "\[AAA\]"

if you replace [ and ] by \\\\[ and \\\\] and print it you will see "\\[AAA\\]" on the console but the string value will be "\\\\[AAA\\\\]" and not "\\[AAA\\]"

so if you replace [ and ] by \\[ and \\] and print it you will see "\[AAA\]" in the console but the string value will be "\\[AAA\\]" like your direct input wich work.

and i check you can use directly :

context.MAIL_Subject = context.MAIL_Subject.replace("[","\\[").replace("]","\\]");

it will works too.

RA6
Creator
Creator
Author

Thank you so much. It works!