Archived Forum Post

Index of archived forum posts

Question:

IMAP Push - alert rather than polling for new email (Google mail)

Oct 30 '13 at 11:14

Is there a way (sample code) in vb(6) interface to ChilkatImap to get push alerts rather than polling every few

minutes

I have an email app that polls to check for new google email every few minutes but would rather have an instant

notice like on smart phones of new mail. A push alert ref: http://www.isode.com/whitepapers/imap-idle.html

email vb6 ChilkatImap

Thanks,


Answer

Please read this: http://www.chilkatforum.com/questions/4391/how-to-trigger-an-event-that-calls-my-application-when-something-external-happens

and then think about how it could be possible to receive Push alerts. The only possible way is to either poll the socket, or to be waiting indefinitely in a socket read operation waiting for a notification to arrive.

An application would do this by creating a background thread to wait for data to arrive on the socket. Of course, when it does, it's an untagged IMAP response such that the content of the response would need to be communicated in some way to the application so that the application could take the appropriate response.

You can see how the client-server IDLE mechanism works here:

               C: A004 IDLE
               S: * 2 EXPUNGE
               S: * 3 EXISTS
               S: + idling
               ...time passes; another client expunges message 3...
               S: * 3 EXPUNGE
               S: * 2 EXISTS
               ...time passes; new mail arrives...
               S: * 3 EXISTS
               C: DONE
               S: A004 OK IDLE terminated
If Chilkat was to introduce IDLE functionality, it would have to be in three method calls:

  1. A method to initiate IDLE.
  2. A method to wait for any untagged responses, perhaps waiting indefinitely, but this is still a polling operation where the poll time can be from 0 seconds to infinite. The caller would need to know what to do with one or more untagged responses.
  3. A method to terminate the IDLE.

Unless your program is multi-threaded, there's really no point in implementing IDLE because you're still going to be doing periodic polling. If you didn't then your program's thread of execution would be simply waiting on the connected socket (and it would be doing nothing else).

At this time, Chilkat has not implemented IDLE. It may do so in the future, but it's a piece of functionality that requires more effort and understanding on the part of the application developer, and it does not even make sense unless the IDLE functionality happens in a background thread.


Answer

I hope the offer this in future!! Low background local polling better than polling Google server constantly which is what I've implemented. (every 4 minutes poll google email - so long wait for email notice, I hear my iPhone ding instantly on new message) I'm just looking for an alert (new mail) then can retrieve additional info.