1
votes

I´m trying to fetch all messages uids from specific folder to extract all posible information.

If input is "INBOX" the output are all messages from all folders in emails.

If the input is the folder I want to get uids, it returns "The requested folder could not be found."

This is the code:

IMailFolder mailFolder = imapClient.GetFolder(Folder);
mailFolder.Open(FolderAccess.ReadOnly);

DataTable dt = new DataTable();

dt.Columns.Add("UID", typeof(String));
dt.Columns.Add("Subject", typeof(String));
dt.Columns.Add("From Name", typeof(String));
dt.Columns.Add("From Address", typeof(String));
dt.Columns.Add("Date Sent", typeof(DateTime));
dt.Columns.Add("MessageID", typeof(String));

for (int i = 0; i < mailFolder.Count; i++)
{
DataRow dr = dt.NewRow();

MimeKit.HeaderList header = mailFolder.GetHeaders(i);
dr["Subject"] = header["Subject"];
dr["MessageID"] = header["Message-ID"];

dt.Rows.Add(dr);
}

Emails = dt;

And how can I extract SenderName,Body, SenderEmail, DateReceived and attachments??

Thank you

1
What server? What are the contents of Folder? - Max
Its Gmail, I connect and extract all UIDS messages from all folders, but i want only from specific input folder - ZiZaK
Max was asking what the Folder string contains - as in: is it "[Gmail]/All"? What folder path does it specify? If you are getting details for all messages, then you are probably opening the All folder. - jstedfast

1 Answers

0
votes

Finally my original code works fine, the problem was that i created new folders in outlook (linked to gmail), but they doesnt exists in gmail.

When I create folders directly in gmail it works,

Thank you