+2 votes

I am trying to access the different folders and email in it, As I am using Microsoft outlook I have personnel folders which while trying to access says it consists of no emails(has), I am not using either standard servers like gmail or yahoo etc I am currently trying out using my office server address but I can access only INBOX folder and rest of folder UID count is Zero but not.

Code:

In the below code based on the selection of the folder which is displayed using previous method I am getting the subjects of each emails in folder.

   public List<string> demo(string sFolder)
    {
        var lListSubjects = new List<string>();
        string sFromAddress = "";
        string sFromName = "";
        using (Imap imap = new Imap())
        {
            imap.ConnectSSL("",993);   // or ConnectSSL
            imap.UseBestLogin("Email", "Password");
            imap.Select(sFolder);

             List<long> uids = imap.GetAll();
            foreach (long uid in uids)
            {
                IMail email = new MailBuilder()
                    .CreateFromEml(imap.GetMessageByUID(uid));
                string subject = email.Subject;

                string sEmailDate = (email.Date).Value.ToString();
                var dSplitToDateTime = sEmailDate.Split(' ');
                var dGetDate = dSplitToDateTime[0];

                foreach (var sAddress in email.From)
                {
                   sFromAddress = sAddress.Address;
                   sFromName = sAddress.Name;
                }

                lListSubjects.Add(subject);

            }
            imap.Close();
        }
          return lListSubjects;
    }

I am using the trial version for trying out, is this causing problem?

Please help me.Cheers!!!


In the Microsoft Outlook personnel folder the count of emails say in "Draft" is not zero but when I access folder using mail.dll and check for email count it's showing zero.


I tried turning on Logging and searching based on flag but still the result looks the same. I can't even get "sent items" the count of emails are zero which is not in real.

by
Please turn on logging: https://www.limilabs.com/blog/logging-in-mail-dll

What happens if you use Imap.Search(Expression.UID(Range.From(0))); or Imap.Search(Flag.Seen); ?

1 Answer

0 votes

Without the logs I'm not able to help you.

Please turn on logging: https://www.limilabs.com/blog/logging-in-mail-dll

I don't think this problem is with Mail.dll. If the server returns zero counts and Imap.Search/Imap.GetAll return no data, the problem is on the server side.

Most likely, you are connected to a different account - believe me I've seen that many, many times.

by (301k points)
...