0 votes

Hy all,

I'm testing your MailForWindowsPhone dll (version 5/6/2915).

Following this example: https://www.limilabs.com/blog/receive-unseen-emails-using-imap, my system throws this:

Message: An unhandled exception of type 'System.IO.FileNotFoundException' occurred in MailForWindowsPhone.DLL
Additional information: Could not load file or assembly 'System.Windows, Version=2.0.6.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' or one of its dependencies. The system cannot find the file specified

More details:
- Using Visual Studio 2013 (version 12.0.31101.00 Update 4) to develop.
- Testing on a device: Lumia 520 (os version 8.10.14219.341).

What can I do to solve this?

Thank you,
Attilio

by (400 points)
Is this Windows Universal project?
I started the Visual C# -> Store Apps -> Windows Phone Apps -> Blank App (Windows Phone)
Does your project reference System.Windows? Are you able to add such reference yourself?
The dll is not referenced in my project, but I can't add it (...I don't know where to find it...).
Use 'add reference' option in your project.
;-) Ok, I'm sorry.. I didn't explain well...

If I open the "Reference Manager" windows I can't find the System.Windows under any tags... The only thing I can try is to browse in file system, but:
1) I don't know where to find it.
2) I don't know which exact version to use(2.0.6.0?)

1 Answer

0 votes
  • The latest version of MailForWindowsPhone.dll is
    Windows Phone Silverlight 8.1 assembly.
  • The latest version of MailForWindowsStore.dll is
    Windows 8 assembly.

Application types and appropriate assembly to use:

  • "Windows 8.1" application should use MailForWindowsStore.dll
  • "Windows Phone 8.1" application should use MailForWindowsStore.dll
  • "Windows Phone Silverlight 8.1" application should use MailForWindowsPhone.dll

In other words:

  • Use MailForWindowsStore.dll for all store apps (Windows 8.1 and Windows Phone 8.1)
  • Use MailForWindowsPhone.dll for Windows Phone Silverlight 8.1

So you should either change (create new) your project type to Windows Phone Silverlight 8.1 -or- Use MailForWindowsStore.dll

by (301k points)
I'm continuing the tests on your API...

The environment is the same:
- Visual Studio 2013.
- Windows 8.1.
- Nokia Lumia 520.

First case: try to download unread e-mail from Gmail in a console application using the example on your web site. I'm using the "Mail.dll" version 3.0.15091.1036, runtime version v2.0.50727. Here the code:

using (Imap imap = new Imap())
{
    imap.ConnectSSL("imap.gmail.com");
    imap.UseBestLogin("myUsername", "myPassword");

    imap.SelectInbox();

    List<long> uids = imap.Search(Flag.Unseen);
    foreach (long uid in uids)
    {
    var eml = imap.GetMessageByUID(uid);
        IMail mail = new MailBuilder().CreateFromEml(eml);

        Console.WriteLine(mail.Subject);
        Console.WriteLine(mail.Text);
        }
        imap.Close();
    }
    Console.ReadKey();

}

The test goes perfectly!!!

Second case: try to download unread e-mail from Gmail in a Windows Phone 8.1 app (project: Visual C# -> Store Apps -> Windows Phone Apps). I'm using the "MailForWindowsStore.dll" version 3.0.14345.1944, runtime versione v4.0.30319. Here the code:

   using (Imap imap = new Imap())
   {
      await imap.ConnectSSL("imap.gmail.com");
      await imap.UseBestLoginAsync("myUsername", "myPassword");
      await imap.SelectInboxAsync();

      List<long> uids= await imap.SearchAsync(Flag.Unseen);
      foreach (long uid in uids)
      {
         var eml = await imap.GetMessageByUIDAsync(uid);
         IMail mail = new MailBuilder().CreateFromEml(eml);
      }
      await imap.CloseAsync();
   }

Systems return my an NullreferenceException on "await imap.ConnectSSL("imap.gmail.com");"; here the call stack:

   at Limilabs.Client.IMAP.ImapResponse..ctor(String tag)
Hi guys,

downloaded and tested... Get some problems:
- "imap.ConnectSSL("imap.gmail.com");" doesn't set imap.ServerGreetings (it remains null and not e.g. "Gimap ready for requests from 151.30.67.61 a9mb152752579wla").
- "imap.Login("myUsername", "myPassword");" throws an exception: Limilabs.Client.ServerExceptions: Please connect first.
You forgot to use await on all async methods.
Thank you for the suggestion...

Another problem :( I receive this exception: "The certificate's CN name does not match the passed value. (Exception from HRESULT: 0x800B010F)"

What do you suggest?
This is not Mail.dll problem. You must be using incorrect server name (different than the one used by the server's certificate)
You are right! Problem solved. ;-)

Now I have a small favor to ask: could you provide me/to the community a working example of downloading mails via IMAP protocol on Windows Phone?

Thank you,
Attilio
I'm not sure what you mean use GetMessageByUIDAsync to download emails and MailBuilder class to parse them. The code snippets you already use are correct way of doing this.
...