|
|
|
|
- Principle
- Examples
- Browsing emails via a FOR EACH loop
- Browsing emails via a WHILE loop
How to read emails via the IMAP protocol?
To read emails via the IMAP protocol without using a messaging software: - Retrieve the parameters for connecting to your messaging server. These parameters are supplied by your Internet service provider or by your network administrator.
- Declare an emailIMAPSession variable and initialize it with the parameters retrieved beforehand.
- Connect to the messaging server with EmailStartIMAPSession.
- Perform a loop to read the emails from the beginning from the end by using EmailReadFirst and EmailReadNext. The Email.Out variable is set to:
- True if there is no message to read.
- False otherwise.
- Use an Email variable to retrieve the content of email that was read.
- Close the IMAP session by using EmailCloseSession.
Browsing emails via a FOR EACH loop
MyMessage is Email MyIMAPSession is emailIMAPSession // Start a simple IMAP session MyIMAPSession.ServerAddress = "imap.mycompany.us" MyIMAPSession.Name = "user" MyIMAPSession.Password = "secret" // Start the IMAP session IF NOT EmailStartSession(MyIMAPSession) THEN // Error starting the IMAP session Error("Unable to start the IMAP session.", ErrorInfo() ELSE // Read the messages FOR EACH MyMessage NOT READ OF MyIMAPSession // Process the message read Trace(MyMessage.Subject, MyMessage.Sender, MyMessage.Message) END // Disconnect from the session EmailCloseSession(MyIMAPSession) END
Browsing emails via a WHILE loop
MyMessage is Email MyIMAPSession is emailIMAPSession // Start a simple IMAP session MyIMAPSession.ServerAddress = "imap.mycompany.us" MyIMAPSession.Name = "user" MyIMAPSession.Password = "secret" // Start the IMAP session IF NOT EmailStartSession(MyIMAPSession) THEN // Error starting the IMAP session Error("Unable to start the IMAP session.", ErrorInfo() ELSE // Read the messages EmailReadFirst(MyIMAPSession, MyMessage) WHILE NOT Email.Out // Process the message read Trace(MyMessage.Subject, MyMessage.Sender, MyMessage.Message) // Read the next message EmailReadNext(MyIMAPSession, MyMessage) END // Disconnect from the session EmailCloseSession(MyIMAPSession) END
This page is also available for…
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|