Quantcast
Channel: ImapX 2
Viewing all articles
Browse latest Browse all 1952

New Post: Idle on Office 365

$
0
0
While my code receieves "Message arrived" notifications from gmail, it does not receieves those notifications from Office 365.
I followed this link and indeed I get true for client.Capabilities.Idle;

Could this be related to authentication?

Do you know if office 365 limits IMAP idle to OAuth authentication?

this is the code (igore the red underlines - it compiles and run):
public void Do(string username, string password)
    {

        var client = new ImapClient(serverUrl, port, SslProtocols.Default, serverCertificate);
        client.Behavior.NoopIssueTimeout = 200;

        var connected = client.Connect();
        var loggedIn = client.Login(username, password);

        var supportsIdle = client.Capabilities.Idle;
        var inbox = client.Folders.Inbox;
        //inbox.Messages.Download();

        Console.WriteLine("set listining on message arrived");
        inbox.OnNewMessagesArrived += Folder_OnNewMessagesArrived;
        inbox.StartIdling(); ;

        Console.WriteLine("Start listen to message arrived notification");

        while (true)
        { }
        var msgs = inbox.Messages;


    }

    void Folder_OnNewMessagesArrived(object sender, IdleEventArgs e)
    {

            foreach (var message in e.Messages)
            {
                Console.WriteLine(message.Subject);
            }


        // New messages arrived
        // e.Folder: The folder in which the messages have arrived
        // e.Messages: The new messages
    }

Viewing all articles
Browse latest Browse all 1952

Trending Articles