cancel
Showing results for 
Search instead for 
Did you mean: 

Outlook VBO - Reply to Email

IshanMahajan
Level 7
Hi,

When i am using Outlook VBO, Reply to Email action, it is sending mails but they are going out as new mail not as a reply, subject line misses RE: in subject line and generated mail does not show the mail thread.

Any suggestion to fix this ?

I am using BP 6.4.3a

------------------------------
Ishan Mahajan
India
------------------------------
1 BEST ANSWER

Helpful Answers

AmiBarrett
Level 12
In the version of the VBO I posted, I replaced the HTMLBody definition. The code below assumes an additional input called HTML (Flag) that determines if it should pull the plaintext or HTML version of the message.

'reply.HTMLBody = Message & vbCrLf & item.HTMLBody

Dim ForwardBody as String

if HTML = True then
	reply.BodyFormat = 2
	ForwardBody = "*****Original Message*****" & "<br>" & "From: " & item.SentOnBehalfOfName & " [mailto:" & item.SentOnBehalfOfName & "]<br>" & "Sent: " & Format(item.ReceivedTime, "dddd, MMMM dd, yyyy ") &Format(item.ReceivedTime, "h:mm:ss tt") & "<br>" & "To: " & item.To & "<br>Subject: " & item.Subject
	reply.HTMLBody = MailBody & "<br><br><p>" & ForwardBody & "</p><br>" & item.HTMLBody
	reply.Display
else
	ForwardBody = "*****Original Message*****" & vbNewLine & "From: " & item.SentOnBehalfOfName & " [mailto:" & item.SentOnBehalfOfName & "]" & vbNewLine & "Sent: " & Format(item.ReceivedTime, "dddd, MMMM dd, yyyy ") & Format(item.ReceivedTime, "h:mm:ss tt") & vbNewLine & "To: " & item.To & vbNewLine & "Subject: " & item.Subject 
	reply.Body = MailBody & vbCrlf & vbCrlf & vbCrlf & ForwardBody & vbCrlf & vbCrlf & item.Body
end if​


------------------------------
Ami Barrett
Sr Product Consultant
Blue Prism
Richardson, TX
------------------------------

View answer in original post

3 REPLIES 3

david.l.morris
Level 15
You could make your own Reply action, and just change the code to put in RE: and include text from the previous message. I glanced at the code for the Reply to Email action, and I it looks like it attempts what it's supposed to, but it does the same thing for me.

------------------------------
Dave Morris
3Ci @ Southern Company
Atlanta, GA
------------------------------

Dave Morris, 3Ci at Southern Company

AmiBarrett
Level 12
In the version of the VBO I posted, I replaced the HTMLBody definition. The code below assumes an additional input called HTML (Flag) that determines if it should pull the plaintext or HTML version of the message.

'reply.HTMLBody = Message & vbCrLf & item.HTMLBody

Dim ForwardBody as String

if HTML = True then
	reply.BodyFormat = 2
	ForwardBody = "*****Original Message*****" & "<br>" & "From: " & item.SentOnBehalfOfName & " [mailto:" & item.SentOnBehalfOfName & "]<br>" & "Sent: " & Format(item.ReceivedTime, "dddd, MMMM dd, yyyy ") &Format(item.ReceivedTime, "h:mm:ss tt") & "<br>" & "To: " & item.To & "<br>Subject: " & item.Subject
	reply.HTMLBody = MailBody & "<br><br><p>" & ForwardBody & "</p><br>" & item.HTMLBody
	reply.Display
else
	ForwardBody = "*****Original Message*****" & vbNewLine & "From: " & item.SentOnBehalfOfName & " [mailto:" & item.SentOnBehalfOfName & "]" & vbNewLine & "Sent: " & Format(item.ReceivedTime, "dddd, MMMM dd, yyyy ") & Format(item.ReceivedTime, "h:mm:ss tt") & vbNewLine & "To: " & item.To & vbNewLine & "Subject: " & item.Subject 
	reply.Body = MailBody & vbCrlf & vbCrlf & vbCrlf & ForwardBody & vbCrlf & vbCrlf & item.Body
end if​


------------------------------
Ami Barrett
Sr Product Consultant
Blue Prism
Richardson, TX
------------------------------

Thanks Ami, that worked.

i know, I am responding way too late 🙂

below is what i used 

Dim app = CreateObject("Outlook.Application")
Dim _nameSpace As Microsoft.Office.Interop.Outlook.NameSpace = app.GetNameSpace("MAPI")

Dim item = _nameSpace.GetItemFromID(Entry_ID)
Dim reply = item.Reply
Dim ForwardBody as String

If String.IsNullOrEmpty(Subject) Then
If Left(item.Subject,3) = "RE:" then
reply.Subject = item.Subject
else
reply.Subject = "RE: " & item.Subject
end if
Else
reply.Subject = Subject
End If

If Message_Is_HTML Then
reply.BodyFormat = 2
ForwardBody = "*****Original Message*****" & "<br>" & "From: " & item.SentOnBehalfOfName & " [mailto:" & item.SentOnBehalfOfName & "]<br>" & "Sent: " & Format(item.ReceivedTime, "dddd, MMMM dd, yyyy ") &Format(item.ReceivedTime, "h:mm:ss tt") & "<br>" & "To: " & item.To & "<br>Subject: " & item.Subject
reply.HTMLBody = Message & "<br><br><p>" & ForwardBody & "</p><br>" & item.HTMLBody
reply.Display
Else
ForwardBody = "*****Original Message*****" & vbNewLine & "From: " & item.SentOnBehalfOfName & " [mailto:" & item.SentOnBehalfOfName & "]" & vbNewLine & "Sent: " & Format(item.ReceivedTime, "dddd, MMMM dd, yyyy ") & Format(item.ReceivedTime, "h:mm:ss tt") & vbNewLine & "To: " & item.To & vbNewLine & "Subject: " & item.Subject
reply.Body = Message & vbCrlf & vbCrlf & vbCrlf & ForwardBody & vbCrlf & vbCrlf & item.Body
End If

If Sensitivity = Int(Sensitivity) AndAlso (Sensitivity >= 0 And Sensitivity <= 3)
reply.Sensitivity = Sensitivity
Else
reply.Sensitivity = 0
End If

If Importance = Int(Importance) AndAlso (Importance >= 0 And Importance <= 2) Then
reply.Importance = Importance
Else
reply.Importance = 1
End If

reply.Send



------------------------------
Ishan Mahajan
India
------------------------------