I’m trying this code, it only work to search a word but not a sentence separated by space.
I’m wondering why.
The code you linked only appears to search for “FTP2”, not a word or sentence. Can you show us yuor code section that in not doing what you expect?
If you paste into a forum message, please prefix and suffix with three back ticks, or highlight the block and click the forum preformatted text icon ( </> ) in the message pane. This makes code MUCH more readable in a message.
GetWord = "Testing Sentence"
messageSet = imap1.Search("SUBJECT " + GetWord,fetchUids)
Always return failed when the email exist. If I just search Testing, it works.
I don’t know anything about IMAP, but what if you encode the query using EncodeURLComponent (in other words, replace the space with %20
)?
GetWord = EncodeURLComponent("Testing Sentence")
messageSet = imap1.Search("SUBJECT " + GetWord,fetchUids)
Same result. I see that in the documentation
Note: It seems that Microsoft IMAP servers, such as outlook.office365.com and imap-mail.outlook.com do not support anything other than 7bit us-ascii chars in the search criteria string, regardless of the SEARCH charset that might be specified.
Everything I saw about multi word searches had quotes around the search string… Maybe that?
BINGO ! Thanks a lot