0 votes
by (180 points)

When saving an e-mail with Rebex.Secure.Mail the flag "X-Message-Flag: Follow up" is saved but not the flag status. When creating a copy of the saved mail, the status of the flag: Follow Up is no longer correct.
I have tried the mail formats .eml and .msg. With both mail formats the result is the same.
Is there a way to query and set the flag status?
Best Regards from Othmarsingen

Applies to: Rebex Secure Mail

1 Answer

0 votes
by (70.2k points)

Please note that Rebex.Secure.Mail saves everything the IMAP server provides.
It means all headers, keywords, etc.

You did not specify what you mean by "the status of the flag: Follow Up is no longer correct". I suppose that you mean displaying the downloaded mail message in Microsoft Outlook.

Please note that the flag status in Microsoft Outlook/Exchange is stored in various MAPI (MSG format) properties, which are unrelated to MIME and those properties are not sent over the IMAP protocol.

To say it short: Unfortunately, there is no possibility to retrieve message flag status using IMAP protocol. Please use the EWS protocol instead. It can be retrieved like this:

// connect and login
var client = new Rebex.Net.Ews();
client.Connect("server", SslMode.Implicit);
client.Login("user", "password");

// get messages
var list = client.GetMessageList(EwsFolderId.Inbox, EwsItemFields.Full);

// print flag statuses
foreach (var item in list)
{
    Console.WriteLine(item.Flag?.Status);
}
by (180 points)
Thank you for your answer.
We store the emails locally to archive the email into a DMS.
I use ews.GetMessage(messageId, @"C:\data\message.eml");, or
MailMessage message = ews.GetMailMessage(messageId);
message.Save(filePath,MailFormat.OutlookMsg);
Unfortunately, this does not save the flag status as well, is there any other way to save that email so that the flag status is also saved?
Thanks a lot
by (70.2k points)
Please note that information about Flag status is not stored in the MIME content. It is stored in the EWS item metadata.

The GetMessage() and GetMailMessage() download the MIME message. To get flag status, either use GetMessageList() method as shown in my answer, or use the GetMessageInfo() method, like this:

    var info = client.GetMessageInfo(messageId, EwsItemFields.Info);
    Console.WriteLine(info.Flag?.Status);

Please note that the GetMessage() method downloads and saves raw MIME data of the email. The GetMailMessage() parses the raw MIME data into MailMessage object, which can be modified. You can for example set Flag status into a MIME header before saving the message to disk. However, parsing take some time and memory, you can for example first write the Flag status into the desired file (in form of MIME header), then download the message using GetMessage() method into the file-stream.
Or you can save the Flag status into a separate metadata file, database, or whatever else.
...