(CkPython) Upload (Append) Email to an IMAP Mailbox
Upload / append an email to an IMAP mailbox.
import sys
import chilkat
# This example assumes the Chilkat API to have been previously unlocked.
# See Global Unlock Sample for sample code.
imap = chilkat.CkImap()
# Connect to an IMAP server.
# Use TLS
imap.put_Ssl(True)
imap.put_Port(993)
success = imap.Connect("imap.someMailServer.com")
if (success != True):
print(imap.lastErrorText())
sys.exit()
# Login
success = imap.Login("myLogin","myPassword")
if (success != True):
print(imap.lastErrorText())
sys.exit()
email = chilkat.CkEmail()
# Load the email from a .eml file.
success = email.LoadEml("myEmail.eml")
if (success != True):
print(email.lastErrorText())
sys.exit()
success = imap.AppendMail("Inbox",email)
if (success != True):
print(imap.lastErrorText())
sys.exit()
print("Email uploaded to Inbox!")
# Disconnect from the IMAP server.
success = imap.Disconnect()
|