+1 vote

HI
I have purchased your licence but got bit confused while integrating it in the application the problem is when i Integrate the Below Code in the application its Working fine but when the same code i am integrating with web API its giving me error.M i missing something?:

using (Imap imap = new Imap())
{
    imap.ConnectSSL("imap.gmail.com", 993);  // or ConnectSSL for SSL 
    imap.UseBestLogin("...........", ".......");

    imap.Select("[Gmail]/All Mail");

    List<long> uids = imap.Search()
        .Where(Expression.GmailRawSearch("after:2016/04/16"))
        .Where(Expression.GmailRawSearch("Ajayara@trimaxamericas.com"));

    foreach (long uid in uids)
    {
        byte[]eml = imap.GetMessageByUID(uid);
        IMail email = new MailBuilder().CreateFromEml(eml);
    }
}
by

1 Answer

0 votes

Examine the error you are getting carefully. Without the error message it's hard to tell what's wrong.

Make sure your application has enough permissions to open a socket connection to Gmail server. Connection is made on port 993 (default IMAP protocol).

In many cases shared hosting environments don't allow opening connections - consult your administrator.

Side note: don't use Where method more than once. If you want to join expressions use Expression.And:

List<long> uids = imap.Search().Where(
    Expression.And(
        Expression.GmailRawSearch("after:2016/04/16"),
        Expression.To("Ajayara@trimaxamericas.com")
    );

I'm not sure if GmailRawSearch can be used more then once - this is GMail specific command, so I'm not sure if standard IMAP search operators apply.

by (301k points)
edited by
...