+1 vote

One message is saved in Inbox and some other folder like Archives.Then how to find out that message is places in both folders or not

by (450 points)

1 Answer

0 votes
 
Best answer

I assume you are probably using Gmail.

The easiest way to work with Gmail is to always use All Mail folder and apply labels to emails.

Here's the example to list all labels for all messages in the INBOX:

using (Imap imap = new Imap())
{
    imap.ConnectSSL("imap.gmail.com");
    imap.UseBestLogin("pat@gmail.com", "password");

    imap.SelectInbox();

    List<long> uids = imap.GetAll();
    List<messageInfo> infos = imap.GetMessageInfoByUID(uids);

    foreach (MessageInfo info in infos)
    {
        List<string> labels = info.GmailLabels.Labels;

        Console.WriteLine("[{0}] {1}",
            string.Join(" ", labels.ToArray()),
            info.Envelope.Subject);
    }
    imap.Close();
}

Get Gmail labels for specified messages:
https://www.limilabs.com/blog/get-gmail-labels-for-specified-messages

Label message with Gmail label:
https://www.limilabs.com/blog/label-message-with-gmail-label

by (282k points)
selected by
...