Hi Peeps,
Greetings!
Is there any video Tutorial regarding email automation using OpenRPA?
Many thanks and cheers,
Hi Peeps,
Greetings!
Is there any video Tutorial regarding email automation using OpenRPA?
Many thanks and cheers,
@willowdan
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,
Greetings!
Surely Iâll give that a try, as I plan to explore Node-RED soon.
Many thanks and cheers,
dante
use this vb.net code to read mail from gmail you can just need to replace variables value according to your configuration.
Try
â 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
Directory.CreateDirectory(localInbox)
End If
' Create app password in Google account
' https://support.google.com/accounts/answer/185833?hl=en
' Gmail IMAP server is "imap.gmail.com"localInbox
Dim oServer As New MailServer("imap.gmail.com",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")
oClient.Connect(oServer)
Console.Write(ArgSearchFilter)
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)
ArgMails.Add(oMail)
Console.WriteLine("From: {0}", oMail.From.ToString())
Console.WriteLine("Subject: {0}" & vbCr & vbLf, oMail.Subject)
Console.WriteLine("Body: {0}" & vbCr & vbLf, oMail.TextBody)
Next
' Quit and expunge emails marked as deleted from IMAP server.
oClient.Quit()
Console.WriteLine("Completed!")
Catch ep As Exception
Console.WriteLine(ep.Message)
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 ).
You can use python or vb.net too like @yashshah showed here.
import imaplib
import email
from email.header import decode_header
# Email account settings
username = "your_email@gmail.com"
password = "your_password"
imap_server = "imap.gmail.com"
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"
mail.select(mailbox)
# Search for emails based on criteria (e.g., UNSEEN for unread emails)
status, email_ids = mail.search(None, "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)
else:
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")
print("Body:")
print(body)
# Close the mailbox and log out
mail.close()
mail.logout()
Hope this help!
Yes . You just have to add invoke code activity in your sequence then select the language to python . Then use this code.
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!
Hello,
Greetings!
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,
willowdan
Hi @yashshah ,
Greetings!
A road block for me in the app password, seemingly I cannot create one for my Google account âŚ
Many thanks,
willowdan
You can use your google login password in that case
Please make sure you enable less secure apps and disable 2 steps authentication in your google account.
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
Many thanks in advance,
willowdan
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.
IMPSGetMail.json (11.8 KB)
Try this code
Hi @Allan_Zimmermann ,
Greetings!
Will try the Node-Red route later .
Many thanks and cheers,
Willowdan
I just looked inside it, itâs a openrpa workflow, so you can import it, after selecting a project inside the first tab.
Hi @yashshah and @Allan_Zimmermann ,
I encountered this error when I imported the json file:
Many thanks in advance,
Willowdan