ImapSmtp is a library for sending, reading, and deleting emails. ImapSmtp is interfacing with SMTP and IMAP protocols.

*About criteria argument*

Various keywords like List Messages and Move Messages have keyword argument called criterion which can be used to filter emails according to given criteria.

Syntax needs to according to specification and more information about that can be read from


  • Authentication error with GMail - "Application-specific password required"


  • More secure apps (XOAUTH2 protocol) - Use the OAuth2 flow as in this Portal robot:


    Make sure to specify a provider (and optionally a tenant) when importing the library and planning to use this flow.


Robot Framework

It is highly recommended to secure your passwords and take care that they are not stored in version control by mistake. See RPA.Robocorp.Vault to see how to store secrets in Robocorp Vault.

When sending HTML content with IMG tags, the src filenames must match the base image name given with the images parameter.

*** Settings ***
Library     RPA.Email.ImapSmtp  smtp_port=587
Task Setup  Authorize  account=${GMAIL_ACCOUNT}  password=${GMAIL_PASSWORD}

*** Variables ***
${BODY_IMG1}            ${IMAGEDIR}${/}approved.png
${BODY_IMG2}            ${IMAGEDIR}${/}invoice.png
${EMAIL_BODY}     <h1>Heading</h1><p>Status: <img src='approved.png' alt='approved image'/></p>
...               <p>INVOICE: <img src='invoice.png' alt='invoice image'/></p>

*** Tasks ***
Sending email
    Send Message  sender=${GMAIL_ACCOUNT}
    ...           recipients=${RECIPIENT_ADDRESS}
    ...           subject=Message from RPA Robot
    ...           body=RPA Robot message body

Sending HTML Email With Image
    [Documentation]     Sending email with HTML content and attachment
    Send Message
    ...                 sender=${GMAIL_ACCOUNT}
    ...                 recipients=${RECIPIENT_ADDRESS}
    ...                 subject=HTML email with body images (2) plus one attachment
    ...                 body=${EMAIL_BODY}
    ...                 html=${TRUE}
    ...                 images=${BODY_IMG1}, ${BODY_IMG2}
    ...                 attachments=example.png


from RPA.Email.ImapSmtp import ImapSmtp

gmail_account = "ACCOUNT_NAME"
gmail_password = "APP_PASSWORD"

mail = ImapSmtp(smtp_server="", smtp_port=587)
mail.authorize(account=gmail_account, password=gmail_password)
    subject="Message from RPA Python",
    body="RPA Python message body",


Initialize self. See help(type(self)) for accurate signature.