| Author |  | 
      
        | palanka Newbie
 
  
 
 Joined: 19 January 2009
 Location: United States
 Online Status: Offline
 Posts: 7
 | 
          how do i capture notification that a new message has arrived?
           | Posted: 19 January 2009 at 7:57am | IP Logged |   |  
           | 
 |  
 i am running against a gmail account if that makes any difference.
 
 my small application must monitor a gmail account 24x7 and pick up any new message as soon as it arrives.   i have the imap demo2 application running successfully against a gmail account already (many thanks for the demo!)
 
 any suggestions?
 
 thanks,
 tim
 | 
       
        | Back to Top |     | 
       
       
        |  | 
        | Igor AfterLogic Support
 
  
 
 Joined: 24 June 2008
 Location: United States
 Online Status: Offline
 Posts: 6168
 | 
          This can be achieved using IDLE mode provided by appropriate mail server extension.
           | Posted: 19 January 2009 at 8:45am | IP Logged |   |  
           | 
 |  
 You can download a sample application here. It enters IDLE mode, and when there's a new message on IMAP server, the application stops idling, downloads the message and restarts the idling process.
 
 The package includes complete source code and the executable file. You can use this code for developing your application.
 
 Regards,
 Igor
 | 
       
        | Back to Top |     | 
       
       
        |  | 
        | palanka Newbie
 
  
 
 Joined: 19 January 2009
 Location: United States
 Online Status: Offline
 Posts: 7
 | 
          Thanks Igor, your examples have been extremely helpful!
           | Posted: 20 January 2009 at 7:23am | IP Logged |   |  
           | 
 |  
 Tim
 | 
       
        | Back to Top |     | 
       
       
        |  | 
        | palanka Newbie
 
  
 
 Joined: 19 January 2009
 Location: United States
 Online Status: Offline
 Posts: 7
 | 
          Hi Igor,  I seem to have an issue with gmail on the example, see log file.  My firewall is off. I got the same result for port 993 and the default port.
           | Posted: 20 January 2009 at 7:45am | IP Logged |   |  
           | 
 |  
 any ideas?
 
 
 [09:33:22.30] [INFO] Assembly version: 4.0.2.105.
 [09:33:22.28] [INFO] Will resolve host "imap.gmail.com".
 [09:33:22.39] [INFO] Host "imap.gmail.com" resolved to IP address(es) 209.85.133.111, 209.85.133.109.
 [09:33:22.39] [INFO] Will connect to host "imap.gmail.com" on port 993.
 [09:33:22.52] [INFO] Error: SocketException occurred. InnerException message follows: An attempt was made to access a socket in a way forbidden by its access permissions 209.85.133.111:993
 | 
       
        | Back to Top |     | 
       
       
        |  | 
        | Andrew AfterLogic Support
 
  
 
 Joined: 28 April 2006
 Location: United States
 Online Status: Offline
 Posts: 1189
 | 
          The sample we provided you with doesn't have SSL support, but Gmail requires SSL connections. So, you should just enable SSL.
           | Posted: 21 January 2009 at 4:19am | IP Logged |   |  
           | 
 |  
 If enabling SSL (it's important to use SslStartupMode.OnConnect mode) doesn't help, please capture new log file and provide us for examination.
 
 Best regards,
 Andrew
 | 
       
        | Back to Top |     | 
       
       
        |  | 
        | palanka Newbie
 
  
 
 Joined: 19 January 2009
 Location: United States
 Online Status: Offline
 Posts: 7
 | 
          OK i got sslstartupmode set, but still same error:
           | Posted: 21 January 2009 at 9:21am | IP Logged |   |  
           | 
 |  
 imp = new Imap();
 imp.SslMode = SslStartupMode.OnConnect;
 
 imp.Log.Filename = @"log.txt";
 imp.Log.Enabled = true;
 imp.Log.Clear();
 
 imp.Connect(textBoxServer.Text, 993);
 
 log file:
 
 [11:15:44.22] [INFO] Assembly version: 4.0.2.105.
 [11:15:44.19] [INFO] Will resolve host "imap.gmail.com".
 [11:15:45.42] [INFO] Host "imap.gmail.com" resolved to IP address(es) 209.85.133.109, 209.85.133.111.
 [11:15:45.44] [INFO] Will connect to host "imap.gmail.com" on port 993.
 [11:15:46.80] [INFO] Error: SocketException occurred. InnerException message follows: An attempt was made to access a socket in a way forbidden by its access permissions 209.85.133.109:993
 
 
 Thanks again for your help,
 Tim
 | 
       
        | Back to Top |     | 
       
       
        |  | 
        | Igor AfterLogic Support
 
  
 
 Joined: 24 June 2008
 Location: United States
 Online Status: Offline
 Posts: 6168
 | 
          The code itself is fine, but it seems your system experiences concurrent connections limit. Please refer to this article, it contains detailed information on the issue and instructions how to overcome it.
           | Posted: 22 January 2009 at 2:53am | IP Logged |   |  
           | 
 |  
 Regards,
 Igor
 | 
       
        | Back to Top |     | 
       
       
        |  | 
        | palanka Newbie
 
  
 
 Joined: 19 January 2009
 Location: United States
 Online Status: Offline
 Posts: 7
 | 
          Igor, i don't think my system is in the state described in the article, see results below.
           | Posted: 22 January 2009 at 7:37am | IP Logged |   |  
           | 
 |  
 Its interesting that your imapdemo2 solution connects to gmail perfectly.  I studied the differences and the only thing that i see is that imapdemo2 connects using asynchronous BeginConnect/EndConnect and the idle demo using synchronous Connect.  any possibility that is the issue?
 
 tim
 
 Proto  Local  Address          ; Foreign Address         State         & nbsp; PID
 TCP    127.0.0.1:668   &n bsp;      127.0.0.1:49194  ;        ESTABLISHED     2932
 TCP    127.0.0.1:27015         127.0.0.1:49160        ESTABLISHED     2860
 TCP    127.0.0.1:49160         127.0.0.1:27015        ESTABLISHED     2340
 TCP    127.0.0.1:49194          127.0.0.1:668         ;  ESTABLISHED     2252
 TCP    127.0.0.1:58864         127.0.0.1:58865        ESTABLISHED     5320
 TCP    127.0.0.1:58865         127.0.0.1:58864        ESTABLISHED     5320
 TCP    127.0.0.1:58866         127.0.0.1:58867        ESTABLISHED     5320
 TCP    127.0.0.1:58867         127.0.0.1:58866        ESTABLISHED     5320
 TCP    192.168.0.117:59075  &n bsp; 74.201.74.24:12975     ES TABLISHED     2532
 TCP    192.168.0.117:59174  &n bsp; 192.168.0.133:3389     ES TABLISHED     4664
 TCP    192.168.0.117:59337  &n bsp; 72.246.98.91:80       ;  TIME_WAIT       0
 | 
       
        | Back to Top |     | 
       
       
        |  | 
        | palanka Newbie
 
  
 
 Joined: 19 January 2009
 Location: United States
 Online Status: Offline
 Posts: 7
 | 
          I tried my own suggestion - using BeginConnect/EndConnect instead of just Connect - and it did not work.
           | Posted: 24 January 2009 at 3:59pm | IP Logged |   |  
           | 
 |  
 Why does IMAPDemo2 connect successfully to imap.gmail.com, but the IDLE Sample program does not?
 
 tim
 | 
       
        | Back to Top |     | 
       
       
        |  | 
        | Alex AfterLogic Support
 
  
  
 Joined: 19 November 2003
 Online Status: Offline
 Posts: 2207
 | 
          Try IMAP Demo 1, it also uses Connect instead of BeginConnect.
           | Posted: 26 January 2009 at 8:14am | IP Logged |   |  
           | 
 |  
 Regards,
 Alex
 | 
       
        | Back to Top |     | 
       
       
        |  | 
        | palanka Newbie
 
  
 
 Joined: 19 January 2009
 Location: United States
 Online Status: Offline
 Posts: 7
 | 
          Thanks Alex, i tried that, but had the same outcome:
           | Posted: 26 January 2009 at 8:48am | IP Logged |   |  
           | 
 |  
 IMAP Demo1 does not connect
 IMAP Demo2 does connect
 IDLE Sample does not connect
 
 My firewall is off.  I assume all 3 programs operate correctly on your equipment.
 
 have you any other suggestions?
 
 thanks guys,
 tim
 | 
       
        | Back to Top |     | 
       
       
        |  | 
        | Alex AfterLogic Support
 
  
  
 Joined: 19 November 2003
 Online Status: Offline
 Posts: 2207
 | 
          Weird. What happens if you do an opposite thing - modify IMAP Demo 2 and replace BeginConnect with Connect? Is the connection result the same?
           | Posted: 29 January 2009 at 6:51am | IP Logged |   |  
           | 
 |  
 Of course, login stage would not run in this case as the callback function won't be called but maybe the connection itself will complete successfully?
 
 Regards,
 Alex
 | 
       
        | Back to Top |     | 
       
       
        |  | 
        | JonGetty Newbie
 
  
  
 Joined: 08 October 2009
 Location: United States
 Online Status: Offline
 Posts: 1
 | 
          Just Tried IMAP Demo 1 with Alex's example above and this time it worked well. Thanks for this useful thread.
           | Posted: 08 October 2009 at 10:46am | IP Logged |   |  
           | 
 |  | 
       
        | Back to Top |     | 
       
       
        |  | 
        | ailaonzo Newbie
 
  
  
 Joined: 14 October 2009
 Location: Philippines
 Online Status: Offline
 Posts: 2
 | 
          thanks for this. this really helped me
           | Posted: 17 October 2009 at 9:11am | IP Logged |   |  
           | 
 |  | 
       
        | Back to Top |     | 
       
       
        |  | 
        | jerryboone Newbie
 
  
  
 Joined: 22 October 2009
 Location: Philippines
 Online Status: Offline
 Posts: 1
 | 
          i tried what alex said. it worked for me!
           | Posted: 27 October 2009 at 12:04am | IP Logged |   |  
           | 
 |    | 
       
        | Back to Top |     | 
       
       
        |  | 
        | christineb1979 Newbie
 
  
  
 Joined: 27 December 2010
 Location: United States
 Online Status: Offline
 Posts: 2
 | 
          Can anyone give instruction about this?
           | Posted: 27 December 2010 at 8:08pm | IP Logged |   |  
           | 
 |  | 
       
        | Back to Top |       | 
       
       
        |  | 
        | christineb1979 Newbie
 
  
  
 Joined: 27 December 2010
 Location: United States
 Online Status: Offline
 Posts: 2
 | 
          Any help will much appreciated.
           | Posted: 27 December 2010 at 8:09pm | IP Logged |   |  
           | 
 |  | 
       
        | Back to Top |       | 
       
       
        |  | 
        | Igor AfterLogic Support
 
  
 
 Joined: 24 June 2008
 Location: United States
 Online Status: Offline
 Posts: 6168
 | 
          christineb1979: what exactly you need help with?
           | Posted: 28 December 2010 at 12:38am | IP Logged |   |  
           | 
 |  
 --
 Regards,
 Igor, AfterLogic Support
 | 
       
        | Back to Top |     | 
       
       
        |  | 
        | bookofradeluxe Newbie
 
  
 
 Joined: 10 October 2011
 Location: Germany
 Online Status: Offline
 Posts: 1
 | 
          Can anyone give instruction about this?
           | Posted: 10 October 2011 at 4:14am | IP Logged |   |  
           | 
 |  | 
       
        | Back to Top |       | 
       
       
        |  | 
        | Igor AfterLogic Support
 
  
 
 Joined: 24 June 2008
 Location: United States
 Online Status: Offline
 Posts: 6168
 | 
          About what exactly, bookofradeluxe?
           | Posted: 10 October 2011 at 4:15am | IP Logged |   |  
           | 
 |  
 --
 Regards,
 Igor, AfterLogic Support
 | 
       
        | Back to Top |     | 
       
       
        |  |