PowerBuilder
PowerBuilder
Connect to an IMAP Server
See more IMAP Examples
Demonstrates the Chilkat Imap.Connect method, which establishes a TCP connection to the IMAP server but does not authenticate. The argument may be a hostname, IPv4, or IPv6 address; configure Ssl and Port first. This example connects with implicit TLS, then logs in and disconnects.
Background: IMAP (Internet Message Access Protocol) is the protocol for accessing mail that stays on the server — unlike POP3, which typically downloads and removes it. That server-side model is what lets multiple devices see the same mailboxes, folders, and read/unread state. A session starts by connecting (usually implicit TLS on port
993), then authenticating — Connect performs only the first step, so it is always followed by Login.Chilkat PowerBuilder Downloads
integer li_rc
integer li_Success
oleobject loo_Imap
li_Success = 0
// Demonstrates the Imap.Connect method, which establishes a TCP connection to the IMAP
// server but does not authenticate. Call Login after connecting to authenticate.
loo_Imap = create oleobject
li_rc = loo_Imap.ConnectToNewObject("Chilkat.Imap")
if li_rc < 0 then
destroy loo_Imap
MessageBox("Error","Connecting to COM object failed")
return
end if
// Use implicit TLS on the standard IMAPS port.
loo_Imap.Ssl = 1
loo_Imap.Port = 993
// Establish the connection to the IMAP server (no authentication yet).
li_Success = loo_Imap.Connect("imap.example.com")
if li_Success = 0 then
Write-Debug loo_Imap.LastErrorText
destroy loo_Imap
return
end if
Write-Debug "Connected to the IMAP server."
// Authenticate the session.
li_Success = loo_Imap.Login("user@example.com","myPassword")
if li_Success = 0 then
Write-Debug loo_Imap.LastErrorText
destroy loo_Imap
return
end if
// Disconnect when finished.
li_Success = loo_Imap.Disconnect()
if li_Success = 0 then
Write-Debug loo_Imap.LastErrorText
destroy loo_Imap
return
end if
destroy loo_Imap