0 votes
by (990 points)
edited

Hello there, I always get an error if i call GetMessageInfo directly after StoreMessage-Method with returned UniqueID as parameter. Here's my code snippet.

Dim sMessageUniqueID As String = oImap.StoreMessage(oImap.CurrentFolder.Name, oMailMessage)

' now we want to get the "new" message id from stored message

Dim oImapMessageInfo As ImapMessageInfo = oImap.GetMessageInfo(sMessageUniqueID, ImapListFields.Fast)

-> Exception: "Message not found."

thank you in advance and have a nice day

Applies to: Rebex Secure Mail
by (148k points)
It looks like your code is OK, the message should have been found. Please use Imap object's LogWriter property to create a log of communication (as described at http://www.rebex.net/kb/logging.aspx) and either mail it to us (support@rebex.net) for analysis or edit your question to include it. We should be able to tell what is going on then.

1 Answer

+1 vote
by (148k points)
edited
 
Best answer

According to the log you sent us, you are using Courier IMAP server and we have been able to reproduce the same issue on it. Calling Imap object's CheckForUpdates method after StoreMessage appears to solve it:

Dim sMessageUniqueID As String = oImap.StoreMessage(oImap.CurrentFolder.Name, oMailMessage)

' force the server to send message status updates
oImap.CheckForUpdates();

' now we want to get the "new" message id from stored message
Dim oImapMessageInfo As ImapMessageInfo = oImap.GetMessageInfo(sMessageUniqueID, ImapListFields.Fast)

This is not needed on most IMAP servers which send the message status updates before the APPEND command (used by StoreMessage method) completes.

We will consider doing this automatically in one of the future releases of Rebex Mail.

by (990 points)
ok, that works. thank you very much. but which ImapListFields-option is the minimum to get the message id?
by (148k points)
What do you mean by message ID, exactly? ImapListFields.SequenceNumber is all you need to get message's sequence number, ImapListFields.UniqueID is all you need to get its unique ID (but you already have that one in sMessageUniqueID. If you would rather have the protocol-level ID instead of its Rebex-only string representation, use ImapMessageSet.ParseUniqueId to parse the sMessageUniqueID into its two parts.
by (990 points)
o sorry. i mean the ImapMessageInfo.MessageId.Id, like <4D7B56BF.8060902@arcor.de> if i use ImapListFields.Fast I did not get it
by (148k points)
I forgot that one, sorry! You need ImapListFields.Envelope to get this MessageId.
...