I try to get messages in inbox folder that where not replied.
At first I used some field in MimeMessage InReplyTo and it was helful.
But today I discovered that some messages that already had replies had this field InReplyTo with null statment. Is there another way to get messages that wheren´t replied?
Related
Is there any limits on how many concurrent clients you can connect to one mail account?
I have an app that opens a new ImapClient on each request. The ImapClient will open INBOX and FolderA, and move a mail by UID from one to another. The multiple clients will never access the same mail concurrent, but probably move multiple mails in same account concurrent.
Errors seems to occur once I hit about 5+ clients simultanious, using Exchange, and response with a lot of different errors as:
"The IMAP server replied to the 'COPY' command with a 'NO' response."
"The IMAP server replied to the 'EXPUNGE' command with a 'NO' response."
When I'm moving mails I do following sequence:
Using a new ImapClient
Connect and auth the client
GetFolderAsync of INBOX and FolderA, then wait for the response
Open the INBOX with OpenSync() with ReadWrite, and wait for the task.
Fetch INBOX with FetchAsync(), looping through the result to find the wanted UID based on MessageID
Calling MoveToAsync() moving the mail based on uid to the FolderA, and waiting
FolderA.SetFlagAsync() with new UID, and flagging the mail with SEEN
Waiting on 6. & 7.
INBOX.SetFlagAsync() with the previous UID, and flagging the mail with DELETED, wait for the operation
Closing IMAP folders using INBOX.CloseAsync and FolderA.CloseAsync
There is no standard that defines the maximum number of clients an IMAP server will allow. I've read that Thunderbird uses a max of 5 concurrent connections (which probably suggests they found that worked well for most IMAP servers in the wild), so that might explain what you are seeing.
What is the best way to be notified instant when mails or changes happens to the INBOX of my mailbox using MailKit??
I have been playing around with following events:
ImapClient.Inbox.CountChanged; This seems to work best when using Exchange servers, since they don't react at all on the MessageArrived event. Pff..
ImapClient.Inbox.MessagesArrived; This seems to work quiet well with open source mail servers, like SquirrelMail, but doesn't work at all with Exchange.
I want to be notified when new mails arrive to the mailbox, if any mails are moved/deleted, and if there any mails moved to this imap folder. Which approach should I take to get an event asap when something happens to my INBOX?? I want the best of both worlds.
And what is the ImapClient.Inbox.Subscribe(); used for??
The Subscribe and Unsubscribe methods just flag a folder (aka mailbox) as subscribed or unsubscribed - generally this is only used by mail clients to decide whether or not the user wants to see the folder in the default folder list.
The CountChanged event is emitted anytime MailKit gets an untagged "* # EXISTS" line from the IMAP server, typically as part of a response to a command that was just sent.
The MessagesArrived event is emitted immediately following the CountChanged event IF AND ONLY IF the new message count is larger than the old message count. Unfortunately, this is a badly designed/named event because it can be very misleading. Since the logic that determines whether or not to emit the event only has limited context (the old message count and the new message count), it can't accurately decide whether or not to emit this event.
Take the following situation for example:
When you open a folder, let's say that the message count is 10.
Now you expunge a handful of messages (5?) out of the folder... BUT, while the messages are being expunged, you get 2 new messages.
When the expunge command completes, the IMAP server replies back with "* 7 EXISTS"
Since 7 (the new message count) is less than 10 (the old message count), the MessagesArrived event will not be emitted.
I want to be notified when new mails arrive to the mailbox, if any mails are moved/deleted, and if there any mails moved to this imap folder.
If you want to know when new messages arrive, you need to listen to the CountChanged event and do your own book keeping to figure out if new messages arrived or if messages were moved/deleted out of the folder.
There's no way to distinguish between messages being moved into the folder vs new messages being delivered to the folder (unless you are doing the moving).
Which approach should I take to get an event asap when something happens to my INBOX??
If your server supports the IDLE extension, you'll probably want to look into using the ImapClient.Idle() (or IdleAsync()) method since the CountChanged event will only be emitted when it receives a "* # EXISTS" response from the server, and an IMAP server will only send that response as part of a response to a command from the client or if the client is in the IDLE mode.
If your server does not support the IDLE extension, you will need to "ping" the IMAP server using the ImapClient.NoOp() method (which is a dummy command that doesn't do anything) periodically in order to check if any new messages have arrived since the last command you sent.
There's an ImapIdle sample in MailKit's GitHub repository to see how to use it.
So,
I want to check if the mail I sent to someone, has a reply. In other words, if that person has replied to my mail.
sentboxFolder =
ns.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderSentbox);
//So here if i access individual mail and check
Outlook.MailItem mailItem = ( Outlook.MailItem ) sentboxFolder.Items[1];
Now, if i took the PR_LAST_VERB_EXECUTED property of this mail item, what would it return if the mail has a reply sitting somewhere in my inbox and what would it return if noone replied to my mail ?
Also,
I'm not sure if I'd be able to implement this properly, can someone refer me to some examples where PR_LAST_VERB_EXECUTED is used?
Thanks in advance
PR_LAST_VERB_EXECUTED is only set on the messages in your local mailbox. If a recipient replied to the message, PR_LAST_VERB_EXECUTED will be set on a message in his/her mailbox, which you most likely cannot access.
You can try to read PR_CONVERSATION_INDEX property from the message in the sent items folder, then search for a message in the Inbox folder that has PR_CONVERSATION_INDEX starting with the same value.
See the following article on MSDN: http://msdn.microsoft.com/en-us/library/office/cc765583.aspx
I was wondering if anyone could help me out (not with code, although that would be appreciated), with the logic behind checking and retrieving messages from a POP3 mail server.
I.e.
Establish connection
Validate credentials
Enumerate message list
Check each message to see if it's "new"
Download "new" message(s).
Would this be the correct way about doing this?
Thank you
The best way of looking at something like this is to have a look what something else does. Run Wireshark or some other packet capture software, and use an e-mail client to check. Anyway, the basics of a POP3 session are as follows:
USER username
PASS password
LIST <-- Shows the size of each waiting message
UIDL <-- Shows a unique ID for each waiting message
RETR 1 <-- Retrieves message with index 1
DELE 1 <-- Deletes the message you just retrieved
QUIT
The first char of all of the responses except RETR will be a + (success) or a - (failure).
If you are deleting messages off the server after retrieving them, you don't need to bother with UIDL. If you are leaving them, you can use UIDL to get a unique ID for each message which you store locally to show you have retrieved that message before.
For more details, see the RFC. Wikipedia also lists a more in depth example, showing the server response.
These should be useful:
POP3 Email Client (.NET 2.0)
POP3 Client as a C# Class
Retrieve Mail From a POP3 Server Using C#
POP3 Sequence Diagram
POP3 Reference
I used smtpclient to send emails, but finally i found that some of the emails can not be reached.
for example:
receiver: aaa#123.com
sometimes, the emails we send to it , and it will receive successfully, but sometimes will not.
at the beginning, I thought it might because that smtp didn't send it successfully, then I use client.sendAsynce, and then add the event handler to handle the SendCompleted event, and i found every emails are sent out successfully, and then we check the smtp server, it really received all the emails and sent out successfully.
So the problem is why sometimes the emails will not be reached successfully, and sometimes will be OK?
You're forgetting one piece of the puzzle - the client email server. Perhaps the emails are being rejected or flagged as spam?