IMAP IDLE / Push

0

I've been trying to look for this. Does your client have IDLE / Push capabilities? I am developing an EMS application that receives the dispatches and needs immediate updates from the IMAP server when a message arrives.

Thanks!

edited 11/16/2017 12:41:36 AM
asked 2/9/2012 2:54:34 PM
add a comment

6 Answers

0
You can use the following code to receive updates of new messages:

        static void Main()
        {
            // IMAP server information.
            const string serverName = "imap.gmail.com";
            const string user = "username@gmail.com";
            const string password = "password";
            const int port = 993;
            const SecurityMode securityMode = SecurityMode.Implicit;

            // Create a new instance of the ImapClient class.
            ImapClient client = new ImapClient();

            // Connect to the server.
            client.Connect(serverName, port, securityMode);

            // Login to the server.
            client.Authenticate(user, password);

            // Select 'INBOX' mailbox
            client.Select("INBOX");

            client.Update += client_Update;

            // ...

            while (true)
            {
                // ...

                // Wait for 10 seconds.
                client.Noop(10000);

                // ...
            }

            // ...

            // Close the connection.
            client.Disconnect();
        }

        static void client_Update(object sender, ImapUpdateEventArgs e)
        {
            switch (e.Event)
            {
                case ImapUpdateEvent.MessageCount:
                    Console.WriteLine("New message received.");
                    // You can download the newly received message here.
                    break;

                case ImapUpdateEvent.MessageRemoved:
                    Console.WriteLine("One or more messages removed.");
                    break;
            }
        }
 
answered 11/16/2017 12:41:36 AM
add a comment
0
Are you already a customer? If yes,we  can send you prerelease DLLs for testing our new DLLs.
 
answered 11/16/2017 12:41:36 AM
add a comment
0

I am not a customer yet. I am part of a volunteer non-profit ambulance company that is using a paid service to receive messages from dispatch. I offered to develop an application that will retrieve the information from the dispatch that is emailed and send it out to our members. Obviously I do not want to spend money on a control to include in my application, but being a VB.Net developer I'm having a hard time finding VB source code that has all of the functions I need. Your control works for NOOPing for new messages, but from what I understand IDLE is a better way to retrieve messages instantly. If there is a version of your control that I can use that will do this requirement, that would be great. Again, all I have to do is "listen" for the new messages, and SMTP them out "parsed" into the necessary information required. No need for folders and real Email client type work. It is a basic "listening" application.

Thanks for the help!

 
answered 11/16/2017 12:41:36 AM
add a comment
0
You can use the Noop(Int32) method to check for updates from the server. Please be advised that when the amount of time is less than 10ms, NOOP command will always be used; otherwise IDLE command will be used.
 
answered 11/16/2017 12:41:36 AM
add a comment
0
Yes, you can handle the Updates event and call Noop method periodically while your application is in idle.
 
answered 11/16/2017 12:41:36 AM
add a comment
0

I have added the evenhandler as below. Unfortunately I must be missing something. After logging on, getting emails, and not disconnecting... isn't there a command that I must send to the IMAP server letting it know that I am IDLING? In other words... I'm waiting for a response? As I stated above, I need an immediate response when a message is received. Sending NOOP every now and again doesn't do the same as IDLE. I've tested other clients, and some have this command built in. When a new message has been sent, the update does not get triggered.

Dim Client As New ComponentPro.Net.Mail.ImapClient

AddHandler Client.Update, AddressOf Client_Update

Client.Connect("XXXXXX")

Client.Authenticate("XXXXX", "XXXX")

Dim sb As New ArrayList

Dim list As MailboxCollection = Client.ListMailboxes()

For i As Integer = 0 To list.Count - 1

   sb.Add("1: " & list(i).Name)

Next i

Client.Select("INBOX")

listMessages = Client.ListMessages()

For Each m As ImapMessage In listMessages

     ShowUltimateMail(m)

Next m

Public Sub Client_Update(ByVal Sender As Object, ByVal e As ComponentPro.Net.Mail.ImapUpdateEventArgs)

'do something

End Sub

 
answered 11/16/2017 12:41:36 AM
add a comment

Your Answer

Not the answer you're looking for? Browse other questions tagged imap or ask your own question.