IMAP search on header not working as expected - imap

I am building library for IMAP my search command works file for the Inbox folder it returns me a number which I can use to fetch the mail. However when I try to search on Sent Items it does not work it does not give an error but just returns Search OK without any numbers. Can you please point out why this behavior. I am hitting Exchange 2010.
My search command is something like:
search all HEADER Message-ID "<cc6aed80-955b-4800-a3ac-6c3942ceecac>"
This is exactly how it is described in http://support.microsoft.com/kb/302965

Possibly of no use, but I ran into possibly the same problem.
In a mailbox with an email from "Bill Gates ", a search with the expression '(FROM "billy#microsoft.com")' returned nothing; a search for '(FROM gates)' return a hit.
I had to change my code to '(HEADER FROM "billy#microsoft.com")' to get it to work.
ALTERNATIVELY:
You may be able to use IMAP4.uid(command, arg[, ...])
See http://docs.python.org/2/library/imaplib.html#imaplib.IMAP4.uid

Related

How to quote colons in graph query

I have some code which gets details of lists in a SharePoint site then later wants to find out if a list with the same name still exists. This works fine except for list names that contain a colon - I find Graph misinterprets the colon and 'corrupts' the URL.
For instance, in Graph Explorer when I give it the following query:
https://graph.microsoft.com/v1.0/sites('mysite.sharepoint.com,aa-aa-aa,bb-bb-bb')/lists('19:abcdef#thread.tacv2_wiki')
The error response contains the following in the 'message' property:
The expression \"sites('mysite.sharepoint.com,aa-aa-aa,bb-bb-bb')/lists('19')/abcdef#thread.tacv2_wiki\" is not valid.
Note that it's split the original URL, thinking the colon is the start of a new segment in the path, even though it's inside a quote.
I've tried all sorts of quoting of the colon (%3A and %253A and %25253A) and different styles of quote characters, but they all either return the same error or give a parsing error.
More information - I specifically want to search by name not by original id (which would be much easier), I'm acutually using Graph Managed API in code but it generates the same error (you'd think it would internally know how to quote), the list is actually a hidden one created in a Teams site to manage channel information.
I was also able to reproduce your issue but as a work around you can use the filter query parameter to get the list by using below query.
https://graph.microsoft.com/v1.0/sites/soaadteam.sharepoint.com,c1178396-d845-46fa-bc0c-453d2951dad5,19ee9a1e-001d-48f1-9ee8-b0adfde54e45/lists?$filter=displayName eq '19:abcdef#thread.tacv2_wiki'

How to fix MS Graph message body search?

Using graph explorer to execute the following message search by subject works as expected:
https://graph.microsoft.com/v1.0/me/messages?$search=%22subject%3Agoogle.com%3A443%2Fsearch%3Fq%3Da%2Btest*%22
However, this message search by body fails. The only difference between this and the previous search is that subject is replaced with body:
https://graph.microsoft.com/v1.0/me/messages?$search=%22body%3Agoogle.com%3A443%2Fsearch%3Fq%3Da%2Btest*%22
The error that I receive for the second search is "An internal server error occurred. The operation failed., Too few pops in query tree".
This search used to work. How do I fix it?
This is a 500 error - you won't make this work. I'll report this as an error. The error appears to be with the second colon in the search string.
$search="body:google.com:443/search?q=a+test*" - this 500s
$search="body:google.com443/search?q=a+test*" - this 200s
Conjecture
I suspect that the search feature now supports multiple fields as the following query works as expected:
https://graph.microsoft.com/v1.0/me/messages?$search="body:Minerva subject:pilot"
This would break your query as it appears that the colon is only considered for specifying the field to search on.
Potential workaround
You could break your query string into multiple parts like this:
https://graph.microsoft.com/v1.0/me/messages?$search="body:google.com AND body:443/search?q=a+test*"
It is not sufficient but may work for your scenario.

Exchange 2010 strange behaviour on search UID SEARCH CHARSET US-ASCII FROM

I'm really spent a lot of time searching about, but no luck.
My issue is not directly related to Mailkit working or not, it is doing right but perhaps someone here have a clue.
I have to look for mails unseen mails from specific mail address on a Exchange 2010 using IMAP. All work fine (until now) for any server except this one.
When "from" mail address in format like John Doe <johndoe#pluto.com> a search for johndoe#pluto.com does not return any UIDs;
John Doe return UID collection;
On the other hand if "from" mail is in plain format all works fine.
Does anybody have any idea or know if is it an issue on Exch2010?
As a work around I'm thinking to make a simple search unseen to get UIDs then Fetch and look at Envelope
By the way here I have on log when message from = John Doe <johndoe#pluto.com>;
C: A00000006 UID SEARCH CHARSET US-ASCII FROM johndoe#pluto.com
S: * SEARCH
S: A00000006 OK SEARCH completed.
Almost 1 year later, seems I found why I canĀ“t get any result when searching From when mail address have Display Name.
Here Dmitry explain Exchange behaviour
https://blogs.technet.microsoft.com/dkhrebin/2013/10/04/how-exchange-imap-search-in-message-header/
A short quote say:
If you use SEARCH FROM (for CC, BCC, TO idea the same) Exchange will search in message's Property: PR_SENT_REPRESENTING_NAME, PR_SENT_REPRESENTING_NAME_A,
ptagSentRepresentingName
The PR_SENT_REPRESENTING_NAME property contains the display name for the messaging user represented by the sender.
So in addition to:SearchQuery.FromContains ("johndoe#pluto.com").Or (SearchQuery.FromContains ("John Doe"));
I can use SearchQuery.HeaderContains ("from", "johndoe#pluto.com");
Since Display Name can be anything and can be changed anytime, and mail address is always same. I can deal with both commands command lines above.
But I can't determine which has the best performance.
I've noticed that each IMAP server seems to behave differently with respect to searching for email addresses and/or Message-Id tokens.
What you may need to do is either do an OR search query:
SearchQuery.FromContains ("johndoe#pluto.com").Or (SearchQuery.FromContains ("John Doe"));
Perhaps that will work around the problem so it works with all IMAP servers?

Advanced site search with google

I try to find out which URLs exists for a specific domain and a specific domain-path in the google index. The urls have the following schema:
https://example.org/path1/<keyword>/path2/
the following google search works fine:
site:https://example.org/path1/*/path2/
but it delivers more than 40.000 findings. So I'll try to search for
https://example.org/path1/a*/path2/
but there where no results found (what can't be). Whats wrong? Any chance to deliver only Findings where Site-URL contains keywords starting with an "a"?
Thank you,
Jan
You can try the following
https://example.org/path1/*a
This will search for all the URL's which starts with https://example.org/path1/ which also contains the keyword a
You can refine your search by specifying multiple keywords:
https://example.org/path1/*a*/path2/
This will search for the same as in the 1st example but will conatin the /path2/ part of the URL as well. However this will match URL's if the keyword a is either before or after the 2nd path /path2/

Can't parse new google urls - HTTP_REFERER doesn't contain parameters anymore

It seems a little odd to my, but although everybody knows about the new google search urls (see Google using # instead of search? in URL. Why?) no one has a problem with the HTTP_REFERER.
I'm using the referrer to parse the google string for the searchquery (&q= ) but as this is all in a hash-tag it wont be sent to the server and all i get is "http://www.google.de/".
So do you know a way of getting the query the user searched for, befor landing on my site?
Due to late-2011 Google security changes, this is no longer possible when the search was performed by a signed-in Google user. See:
http://googleblog.blogspot.com/2011/10/making-search-more-secure.html
http://analytics.blogspot.com/2011/10/making-search-more-secure-accessing.html
Since there are multiple q's in the query string you have to match the "q" parameter globally and take the last one:
/[?|&|#]q=([^&|^#]+)/ig
Get rid of "site:" searches (there are others, but I haven't done them)
/[\+|?|&]?site:([^&|^#])+/g, '');
Then parse the results.
/[\w^'\(\)\{\}]+|"[^"]+"/g
This has been working well for me.

Resources