Any video tutorial regarding email automation using OpenRPA?

Hi Peeps,


Is there any video Tutorial regarding email automation using OpenRPA?

Many thanks and cheers,


I didn’t find a video on this topic, but I have experience reading an email using RPA

You can use the “Get Mail” activity, but in my opinion it is not very convenient, since it only takes emails through Outlook, which is running on the machine on which the process is running. I always use the “Email” block in Node-RED, with which you can connect to the mail server address using one of the mail protocols (you need to download the node-red-node-email extension). Next, you need to obtain the necessary data from the letter object (subject, sender, some link from the body, etc.) and generate a message with parameters that will already go to OpenRPA.
In my opinion this is a pretty convenient way


Hello @Velinkton,


Surely I’ll give that a try, as I plan to explore Node-RED soon.

Many thanks and cheers,

use this code to read mail from gmail you can just need to replace variables value according to your configuration.
’ Create a folder named “inbox” under current directory
’ to save the email retrieved.

        Dim localInbox As String = String.Format("{0}\inbox", Directory.GetCurrentDirectory())

        ' If the folder is not existed, create it.
        If Not Directory.Exists(localInbox) Then
        End If

        ' Create app password in Google account
        ' Gmail IMAP server is ""localInbox
        Dim oServer As New MailServer("",ArgEmail, ArgPassword,ServerProtocol.Imap4)

        ' Enable SSL/TLS connection, most modern email server require SSL/TLS connection by default.
        oServer.SSLConnection = True
        ' Set 993 IMAP SSL Port
        oServer.Port = 993
        Console.WriteLine("Connecting server ...")

        Dim oClient As New MailClient("TryIt")
        Dim MailInfolist As MailInfo() = oClient.SearchMail(ArgSearchFilter)
        Console.WriteLine("Total {0} email(s)", MailInfolist.Length)

        For i As Integer = 0 To MailInfolist.Length - 1
            Dim info As MailInfo = MailInfolist(i)
            Console.WriteLine("Index: {0}; Size: {1}; UIDL: {2}", info.Index, info.Size, info.UIDL)

            ' Retrieve email from IMAP server
            Dim oMail As Mail = oClient.GetMail(info)
            Console.WriteLine("From: {0}", oMail.From.ToString())
            Console.WriteLine("Subject: {0}" & vbCr & vbLf, oMail.Subject)
            Console.WriteLine("Body: {0}" & vbCr & vbLf, oMail.TextBody)



        ' Quit and expunge emails marked as deleted from IMAP server.

Catch ep As Exception
End Try


Hi @willowdan

If you want to test the OpenRPA “Get Mail” activity here is a small demo for you to test (if you need explanation, let me know): GetMailOutlook.json (16.9 KB)
I really like @Velinkton ideia to use Node-RED “Email”, it’s fantastic tool (imagination is the limit :sweat_smile:).
You can use python or too like @yashshah showed here.

import imaplib
import email
from email.header import decode_header

# Email account settings
username = ""
password = "your_password"
imap_server = ""
port = 993  # Specify the custom port here

# Connect to the IMAP server with the custom port
mail = imaplib.IMAP4_SSL(imap_server, port)
mail.login(username, password)

# Select the mailbox you want to read emails from (e.g., "inbox")
mailbox = "inbox"

# Search for emails based on criteria (e.g., UNSEEN for unread emails)
status, email_ids =, "UNSEEN")

# Convert the list of email IDs into a list of individual email IDs
email_id_list = email_ids[0].split()

# Loop through the email IDs and fetch the email content
for email_id in email_id_list:
    # Fetch the email by ID
    status, msg_data = mail.fetch(email_id, "(RFC822)")

    # Parse the email content
    email_message = email.message_from_bytes(msg_data[0][1])
    subject, encoding = decode_header(email_message["Subject"])[0]
    if encoding:
        subject = subject.decode(encoding)
        subject = str(subject)

    # Print email details
    print("Subject:", subject.encode("utf-8", "ignore").decode("utf-8", "ignore"))
    print("From:", email_message["From"])
    print("Date:", email_message["Date"])

    # If you want to extract the email body, you can do so like this:
    for part in email_message.walk():
        if part.get_content_type() == "text/plain":
            body = part.get_payload(decode=True).decode("utf-8")

# Close the mailbox and log out

Hope this help!


Hi @yashshah ,

Does this solution have to be in the “invoke code” activity?


Hi @kowts ,

Does your code have to be in the “invoke code” activity?


Yes . You just have to add invoke code activity in your sequence then select the language to python . Then use this code.

1 Like


Exactly like @Vivek_Sharma explain.

FYI…someone recently implemented a new feature called “ScriptActivities” in openrpa where you can implement this script or any other as a “component” (no need to duplicate the code).
You can find official documentation on github and references here in this forum.

You can run this python script in NodeRed too but you can choose what’s best for your process.

Hope this help!




I just tried this as a python script … and it failed, as can be seen in the image below:

Hope I can get help from you peeps.

Many thanks and cheers,

Hi @yashshah ,


A road block for me in the app password, seemingly I cannot create one for my Google account …

Many thanks,

You can use your google login password in that case

1 Like

Please make sure you enable less secure apps and disable 2 steps authentication in your google account.

1 Like

Hi @yashshah ,

Sorry to disturb you, here’s the new error:

[15:26:47.627][Output] read email failed at 1.5 in 00:01.264

C:\Users\willo\AppData\Local\Temp\kbj45b13.0.vb(32,0) : error BC30002: Type ‘MailServer’ is not defined.C:\Users\willo\AppData\Local\Temp\kbj45b13.0.vb(40,0) : error BC30002: Type ‘MailClient’ is not defined.C:\Users\willo\AppData\Local\Temp\kbj45b13.0.vb(42,0) : error BC32017: Comma, ‘)’, or a valid expression continuation expected.C:\Users\willo\AppData\Local\Temp\kbj45b13.0.vb(43,0) : error BC30002: Type ‘MailInfo’ is not defined.C:\Users\willo\AppData\Local\Temp\kbj45b13.0.vb(47,0) : error BC30002: Type ‘MailInfo’ is not defined.C:\Users\willo\AppData\Local\Temp\kbj45b13.0.vb(51,0) : error BC30002: Type ‘Mail’ is not defined.C:\Users\willo\AppData\Local\Temp\kbj45b13.0.vb(52,0) : error BC30451: ‘ArgMails’ is not declared. It may be inaccessible due to its protection level.

Many thanks in advance,

So in order to use password authentication for gmail you need to go to your account, security settings and enable app authentication/legacy signin ( something like that )
But i vaguely remember reading somewhere google was going to deprace that, and force everyone to use alternatives. Im not sure if that has happended yet.

If that is the case, you need to move to nodered or an agent. In nodered i have made a “reques” node that supports all 3 authentication methods for google cloud/suit. Or you could write the code in python/nodejs/csharp and then use credentials or oauth authentication from there.

1 Like

IMPSGetMail.json (11.8 KB)
Try this code

1 Like

Hi @Allan_Zimmermann ,


Will try the Node-Red route later .

Many thanks and cheers,

Hi @yashshah ,

How is that json used, in invoke code activity?

Many thanks and cheers,

I just looked inside it, it’s a openrpa workflow, so you can import it, after selecting a project inside the first tab.

1 Like

Hi @yashshah and @Allan_Zimmermann ,

I encountered this error when I imported the json file:

Many thanks in advance,