Is it possible to check the email and initiate actions when email received?
For example, if a user has sends an email with the header like ‘ACTION: start downloading report’. Can a UiPath identify that an email has been received with this header and from this start an automated process?
Otherwise, it is possible to monitor a folder instead and when a text file (for example) is saved there to initiate an automated process?
You can monitor events using the activity named Monitor Events. This activity has a trigger section in which you can drop the File change trigger to observe changes on files and folders.
In order to execute actions when receiving mail you’ll have to get the mails from your Outlook account for example and parse the subject of each mail to do a related action.
I know this is slightly … counter-intuitive … to be writing this here … but I have been playing around with Outlook Macros … I feel they are a little over-looked.
The mailbox automation that I wrote used both UiPath and outlook macros.
Private Sub Application_Startup()
Dim olApp As Outlook.Application
Dim objNS As Outlook.NameSpace
Dim olFolder As Outlook.MAPIFolder
Dim olASDAFolder As Outlook.MAPIFolder
Dim msg As Outlook.MailItem
Set olApp = Outlook.Application
Set objNS = olApp.GetNamespace(“MAPI”)
Set olFolder = objNS.GetDefaultFolder(olFolderInbox)
'Set olASDAFolder = olFolder.Folders(“ASDAsickness”)
'default local Inbox
'Set Items = objNS.GetDefaultFolder(olFolderInbox).Items
Set olASDAFolder = objNS.Folders(“Mailbox - Hugh Abbott”).Folders(“sickness”)
Set Items = olASDAFolder.Items
End Sub
Private Sub Items_ItemAdd(ByVal item As Object)
Dim strFileName As String
Dim i As Integer
Dim secStamp As Integer
Dim minStamp As Integer
Dim hrStamp As Integer
secStamp = Second(Now)
minStamp = Minute(Now)
hrStamp = Hour(Now)
I did this some time ago … just as a test. The basic idea is to write a text file every time an email reaches a certain folder … I’m not sure it even works ? But the most important thing is for you to see that it is good old VB. so give it a go !
Hey! here is an example. in this example, if the mail contains attachment then they are saved in a particular folder otherwise bot replies to the sender saying you have forgotten to attach files in the sent mail.
I did something similar and it works fairly well. The codes saves the contents of the email into a text file.
Dim objItem As Object
Dim myFolder As Folder
If Not TypeName(myItem) = "Nothing" Then
If LCase(myMail.Subject) = "SubjectKeyword" Then
strname = myMail.Subject
strdate = Format(myMail.ReceivedTime, "yymmddhhmmss")
myMail.SaveAs "C:\EmailFiles\" & strdate & ".txt", olTXT
End If
End If
End Sub
I have then a process that picks up new files in the folder, reads the contents and acts upon the information received
There is a problem thought that the text is wrapped, so I had to find a way to merge the text
The formatting is lost in my case. Only the text is copied. This works for me as I need to capture the request type and the setting from the users that I use then for the robot in Uipath.
Maybe it is possible to capture the formatting if the email is saved in HTML instead of olTXT. I didn’t test it.