Outlook email reply

How to reply in the same thread of outlook email ?

As per me there is no activity in UiPath that helps in replying to a particular email.
There are workaround that can be tried though which includes-

  1. we can send an email with mail.sender as To, in Subject we can add “RE:”+mail.subject, for body we can append few lines and paste mail.body

However, the above solution is not full proof because it will fail in the case where we are replying an email trail.

2.The other work-around is quite lengthy so kindly bear with me-
Step 1- Import namespace- Microsoft.Office.Interop.Outlook in namespace.

Step 2- Use the invoke code activity in UiPath and paste the following code-

Dim OutlookIns As Microsoft.Office.Interop.Outlook.Application
Dim olNamespace As Microsoft.Office.Interop.Outlook.NameSpace
OutlookIns = New Microsoft.Office.Interop.Outlook.Application()
olNamespace = OutlookIns.GetNamespace(“MAPI”)
Dim myInbox As MAPIFolder
myInbox = olNamespace.GetDefaultFolder(OlDefaultFolders.olFolderInbox)

Dim item As Microsoft.Office.Interop.Outlook.MailItem
Try

For Each item In myInbox.Items
console.WriteLine("Mail Subject line is " +item.Subject)
If (item.Subject.Equals(varDesiredSubject))
Dim item1 As Microsoft.Office.Interop.Outlook.MailItem
item1 = item.Reply()
item.HTMLBody = "Reply Body " & vbCrLf & item.HTMLBody()
item1.Display()
item1.Send()
End If
Next
Catch E As System.Exception
Console.WriteLine(E)
End Try
Console.WriteLine(“Smoothly Finish”)

Step 3- Edit the main.xaml file using notepad and add Microsoft.Office.Interop.Outlook under the tag

image

Step 4- While executing the above xaml you may encounter error.
to resolve that - You can try using an argument in the Invoke code activity.
for instance, suppose you are trying to reply to email with particular subject line.
Then use assign activity to assign that subject line in the variable.
and then in the invoke code - Edit argument pass the variable as argument.
and use that argument in the code.

Hope this helps.

1 Like