Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Last active April 26, 2022 10:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aspose-com-gists/c7412861cf4d24878c1b922133e5862d to your computer and use it in GitHub Desktop.
Save aspose-com-gists/c7412861cf4d24878c1b922133e5862d to your computer and use it in GitHub Desktop.
Connect to IMAP Server in Python | Read Messages from IMAP Server
from aspose.email import ImapClient, SecurityOptions
# Create and initialize IMAP client
client = ImapClient("imap.domain.com", 993, "user@domain.com", "pwd")
# Set security options
client.security_options = SecurityOptions.SSLIMPLICIT
from aspose.email import ImapClient
# Make a connection with IMAP server
with ImapClient("imap.gmail.com", 993, "username", "password") as conn:
# Select folder
conn.select_folder("Inbox")
# List messages
for msg in conn.list_messages():
# Save message
conn.save_message(msg.unique_id, msg.unique_id + "_out.eml")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment