Outlook 2013 Reply Inline With a Outlook Template

mechmetal

New Member
Outlook version
Outlook 2013 32 bit
Email Account
IMAP
I would like to reply to a message inline with a outlook template using a macro.

I am currently using the below code to perform the reply with a template but this opens a pop out reply window.

Sub Reply_Scripting()
Dim origEmail As MailItem
Dim replyEmail As MailItem
Set origEmail = Application.ActiveWindow.Selection.Item(1)
Set replyEmail = Application.CreateItemFromTemplate("C:\Test.oft")
replyEmail.HTMLBody = replyEmail.HTMLBody & origEmail.reply.HTMLBody
replyEmail.Display
End Sub

I have found this code would help to accomplish this, but I do not how to modify it to make work in my case.

Dim myOlApp As New Outlook.Application
Public WithEvents myOlExplorer As Outlook.Explorer

Public Sub Initialize_handler()
Set myOlExplorer = myOlApp.ActiveExplorer
End Sub

Private Sub myOlExplorer_InlineResponse(ByVal Item As Object)
' do things to the Item here in the inline response
End Sub

Thanks.
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
I don't think it will work with a template in the inline editor.

This is how you would do something -
Private Sub myOlExplorer_InlineResponse(ByVal Item As Object)
' do things to the Item here in the inline response
Item.HTMLBody = "yes" & Item.HTMLBody
End Sub

i also tried using filesystemobject to insert stationary as HTML, but it didn't work either - i got background colors but not images (it should work to insert text in an html file). (took it from code at Apply Outlook Stationery to Replies and Forwards
Code:
Private Sub myOlExplorer_InlineResponse(ByVal Item As Object)
' do things to the Item here in the inline response
 Dim fso As Scripting.FileSystemObject
 Dim tsTextIn As Scripting.TextStream
 Dim strTextIn As String
 Dim strInsert As String
 Dim fsoFile As Scripting.File
 Dim fsoFldr As Scripting.Folder

Dim enviro As String
enviro = CStr(Environ("USERPROFILE"))
' your stationery file
StrFile = "C:\Program Files (x86)\Microsoft Office\root\Stationery\1033\dadshirt.htm"

 Set fso = New Scripting.FileSystemObject
 'read html
 Set tsTextIn = fso_OpenTextFile(StrFile)
 strTextIn = tsTextIn.ReadAll


Item.HTMLBody = strTextIn
End Sub
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
i got background colors but not images
i take that back... you need to use the full image path in background images (I'm sure its mentioned in the page i linked... but i didn't read it, only copied the code.:)).

I used this for the htmlbody (in the macro above) - and the pawprint html page.

Item.HTMLBody = strTextIn & Item.HTMLBody

insert-stationery.png
 

mechmetal

New Member
Outlook version
Outlook 2013 32 bit
Email Account
IMAP
Hi Diane, Could you please tell me where should I paste the above code as I could not, get it showing the macros pane to run.
I tried pasting it in both outlook session and modules.
Thanks.
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
You don't run it in the macros pane, you put it in ThisOutlookSession - you may need to restart Outlook or click inside Public Sub Initialize_handler() and press Run before it works.

Because of the way templates (oft files or published forms) work, you can't add them to a reply message and stay in the reading pane - text or html files can be inserted as text, as they are pretty much the same as using Body or HTMLbody.
 

mechmetal

New Member
Outlook version
Outlook 2013 32 bit
Email Account
IMAP
Ok, I pasted the below code in the outlook session and can see it in the macros pane but when I run it nothing happens.

Code:
Dim myOlApp As New Outlook.Application
Public WithEvents myOlExplorer As Outlook.Explorer

Public Sub Initialize_handler()
Set myOlExplorer = myOlApp.ActiveExplorer
End Sub

Private Sub myOlExplorer_InlineResponse(ByVal Item As Object)
' do things to the Item here in the inline response
Dim fso As Scripting.FileSystemObject
Dim tsTextIn As Scripting.TextStream
Dim strTextIn As String
Dim strInsert As String
Dim fsoFile As Scripting.File
Dim fsoFldr As Scripting.Folder

Dim enviro As String

StrFile = "C:\Program Files\Common Files\microsoft shared\Stationery\Bears.htm"

Set fso = New Scripting.FileSystemObject
'read html
Set tsTextIn = fso_OpenTextFile(StrFile)
strTextIn = tsTextIn.ReadAll

Item.HTMLBody = strTextIn & Item.HTMLBody
End Sub
 

mechmetal

New Member
Outlook version
Outlook 2013 32 bit
Email Account
IMAP
Please ignore my previous reply, I was able to get in running but I get following error
upload_2017-10-15_11-29-26.png
 

Similar threads

Top