In IMAP it's pretty straightforward to get the UID for a single message if you happen to have a relative message number:
FETCH 1 (UID)
But suppose you had a UID and later wanted to determine the relative message number for just that message? Does IMAP provide a way to do that?
I'm not seeing anything especially obvious in the spec that would allow you to get the relative message number for a single message. I could do
UID FETCH 1:* (UID)
and then parse and search through the results to find it, but that seems like overkill (not to mention exponentially slow).
Pretty simple:
tag UID FETCH <uid> (UID)
The response will include the message number, not in the fetch information but as the initial part of the response
tag <messagenumber> FETCH (UID <uid>)
Related
I am using the Twitter API's Search Tweets endpoint (https://developer.twitter.com/en/docs/tweets/search/api-reference/get-search-tweets) to search for tweets on a particular topic. My application is written in Java and uses Twitter4j. I follow the guidelines (i.e. no more than 180 calls per minute and no more than 500 characters per query) however I do have a test case that has 50 word exclusions (so the total character count is 397). My test program also runs 100 such searches in rapid succession though, like I said, I observe the rate limits strictly.
The odd behavior I'm seeing is that the test runs fine and gets results initially, but after an arbitrary period of time, I start getting the following error:
Message: Missing or invalid url parameter. 403:The request is understood, but it has been refused. An accompanying error message will explain why. This code is used when requests are being denied due to update limits (https://support.twitter.com/articles/15364-about-twitter-limits-update-api-dm-and-following).
message - Missing or invalid url parameter.
code - 195
The error message confuses me because I'm not trying to perform any of the update actions listed in the link provided. I'm just searching tweets. I'm also not sure what "missing or invalid url parameter" means. Is a query parameter missing from my request? The only required parameter is the query itself which I am definitely passing. The url is definitely correct unless Twitter4j is generating incorrect urls. So what does this message mean?
When I stop and restart the search (i.e. the max_id and since_id values get reset to -1, the searches start working again...for a while. As far as I know, nothing else about the search changes when it is restarted. Just those two ids.
I have a script that connects via TCP/Sockets, Authenticates SSL, and then checks if the response from stream returns "OK".
It then sends a UID search command:
{tag} UID SEARCH (UNDELETED) (SENTSINCE "{RFC2060 Format Date}")
I then follow that with another OK check aswell as a * SEARCH stream response check.
When both of those are not true, I always end up with this as a result from the stream: xm005 NO UID SEARCH State error
Im not certain but is it possible this returns if the email has no UNDELETED inbox or something?
This seems to occur all the time on one of my chinese friends specific accounts on yeah.net (163-China related email service).
When I login to it with Windows 10's Mail App, I can see it has inboxes in CHINESE. Is it possible something to do with that is causing this issue?
I'm essentially wanting to search for every email within the sent-since date that has not been deleted, perhaps (UNDELETED) isn't a global declaration and is an actual inbox or something?
According to IMAPv4.1's RFC:
UNDELETED
Messages that do not have the \Deleted flag set.
So maybe its not to do with Inbox's? regardless its pretty odd that both emails this occurs on have Chinese Inbox's yet my English-Only one works splendid.
I removed (UNDELETED) and attempted running, and the same issue occurs, so it's not that.
The "state" in the error message could mean "your state does not include a mailbox". Make sure to issue a SELECT command before UID SEARCH.
Hi I tried following IMAP commands in Gmail, It is working where as in yahoo not working.
A UID FETCH *:* (UID) (MODSEQ)
A BAD [CLIENTBUG] UID FETCH Additional arguments found after last expected argument
In gmail i am getting MODSEQ as one of the response.
FYI:
In gmail CONDSTORE is one of available capability whereas in yahoo it is not. But still yahoo providing HIGHESTMODSEQ for every SELECT/EXAMINE. if it is maintaining HIGHESTMODSEQ then there is a way to get for per-message basis. please tell me how to archive this in Yahoo....
Thanks...
When the server tells you there's a CLIENTBUG, it is usually right. The syntax for FETCH is on page 85 of RFC 3501. Read it. In this case, the correct version is:
A UID FETCH *:* (UID MODSEQ)
You could also make the list simpler, since UID implies UID and *:* means "from * to *":
A UID FETCH * (MODSEQ)
Or turn the single-item list into a single item:
A UID FETCH * MODSEQ
Using IMAP via telnet, I want to be able to extract the subject from the specific given email. Now I know that the fetch command is responsible for getting data from an email.
My question is, how do I get the subject header specifically, without using a call to BODY[HEADER.FIELDS (SUBJECT)] (which will, in the eyes of the server, 'open the email' and thus set the /seen flag, which is what I don't want to occur)?
I understand FETCH FULL returns the full header, which contains the subject but it's a nightmare to parse through and could be riddled with unseen pitfalls if I manually parse it. How would I get the server to give me just the subject from the header?
I discovered the answer:
BODY.PEEK[HEADER.FIELDS (SUBJECT)]
.PEEK tells it not open it (so /seen isn't set).
Besides BODY.PEEK, you could fetch ENVELOPE, which gives you a parsed summary of much of the message metadata.
"a1 FETCH 1:* (FLAGS BODY[HEADER.FIELDS (SUBJECT DATE FROM)])\r\n"
How do I determine the UID of a message which is added via APPEND to a mailbox? Through STATUS I can get a prediction of the next value beforehand and I can SEARCH afterwards, but relying on these introduces a race condition as other messages might have been added between these commands.
If you IMAP server supports UIDPLUS, you will always get an APPENDUID response. This will contain the UID and the validity period for the UID.
Sample syntax from RFC 4315:
S: A003 OK [APPENDUID 38505 3955] APPEND completed
If your mailserver doesnt support UIDPLUS, you will have to do a FETCH for the UID, once your append operation is finished. If you are sure that no message was added after the append, go look for the last message in the FETCH response.
FETCH 1:* (UID)
If you are worried about other messages getting added, you can save an IMAP header like Message-ID before the APPEND and later use it in the FETCH operation.