DataFlex
DataFlex
Log In to an IMAP Server
See more IMAP Examples
Demonstrates the Chilkat Imap.Login method, which authenticates the connected IMAP session using a login name and password. Connect must be called first. This example connects, logs in, and disconnects.
Background: Authentication is a distinct step from connecting: after the TCP/TLS connection is up,
Login sends the credentials so the server will grant access to the account's mailboxes. The exact mechanism (plain LOGIN, SASL, or OAuth2) depends on the server and the AuthMethod setting. For providers that require OAuth2 (such as Gmail and Outlook.com), the password is an access token rather than an account password.Chilkat DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Boolean iSuccess
Handle hoImap
String sTemp1
Move False To iSuccess
// Demonstrates the Imap.Login method, which authenticates the connected IMAP session using
// a login name and password. Call Connect first.
Get Create (RefClass(cComChilkatImap)) To hoImap
If (Not(IsComObjectCreated(hoImap))) Begin
Send CreateComObject of hoImap
End
Set ComSsl Of hoImap To True
Set ComPort Of hoImap To 993
// Connect before logging in.
Get ComConnect Of hoImap "imap.example.com" To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoImap To sTemp1
Showln sTemp1
Procedure_Return
End
// Authenticate with the login name and password.
Get ComLogin Of hoImap "user@example.com" "myPassword" To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoImap To sTemp1
Showln sTemp1
Procedure_Return
End
Showln "Logged in to the IMAP server."
Get ComDisconnect Of hoImap To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoImap To sTemp1
Showln sTemp1
Procedure_Return
End
End_Procedure