0 votes

Is there any method to find folder path of an email from MessageInfo

by

1 Answer

0 votes

I assume you are talking about IMAP folder location of the message.

No, MessageInfo object doesn't include this information.

You need to remember what you selected using imap.Select(folder) method or use imap.CurrentFolder.Name property.

There is one exception for Gmail though:
MessageInfo.GmailLabels gives you all labels associated with a message.

Good approach when working with Gmail might be selecting 'All Mail' folder and using labels to move messages between them:

CommonFolders common = new CommonFolders(imap.GetFolders());
client.Select(common.AllMail);

MessageInfo> info = imap.GetMessageInfoByUID(uid);
List<string> lables = info.GmailLabels;
by (297k points)
...