|
|
|
|
|
- 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 are no more messages 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
MyIMAPSession.ServerAddress = "imap.mycompany.us"
MyIMAPSession.Name = "user"
MyIMAPSession.Password = "secret"
IF NOT EmailStartSession(MyIMAPSession) THEN
Error("Unable to start the IMAP session.", ErrorInfo()
ELSE
FOR EACH MyMessage NOT READ OF MyIMAPSession
Trace(MyMessage.Subject, MyMessage.Sender, MyMessage.Message)
END
EmailCloseSession(MyIMAPSession)
END
Browsing emails via a WHILE loop MyMessage is Email
MyIMAPSession is emailIMAPSession
MyIMAPSession.ServerAddress = "imap.mycompany.us"
MyIMAPSession.Name = "user"
MyIMAPSession.Password = "secret"
IF NOT EmailStartSession(MyIMAPSession) THEN
Error("Unable to start the IMAP session.", ErrorInfo()
ELSE
EmailReadFirst(MyIMAPSession, MyMessage)
WHILE NOT Email.Out
Trace(MyMessage.Subject, MyMessage.Sender, MyMessage.Message)
EmailReadNext(MyIMAPSession, MyMessage)
END
EmailCloseSession(MyIMAPSession)
END
This page is also available for…
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|