Reply Inline With a Outlook Template

Status
Not open for further replies.

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.
 
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
 
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
 
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.
 
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.
 
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
 
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
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
M Delete headers in Inline reply Outlook VBA and Custom Forms 5
N Reply to Outlook messages by moving messages to a specific Outlook folder Outlook VBA and Custom Forms 1
J Macro to Reply to Emails w/ Template Outlook VBA and Custom Forms 3
J Quick steps delete original email and move reply/sent email to folder Using Outlook 2
nmanikrishnan Auto-reply from default account Using Outlook 1
P Automatic Greeting "Hello Name," when Reply All is clicked Outlook VBA and Custom Forms 1
N Line to move origEmail to subfolder within a reply macro Outlook VBA and Custom Forms 0
A Outlook 2016 Macro to Reply, ReplyAll, or Forward(but with composing new email) Outlook VBA and Custom Forms 0
S How to find emails that I sent that have not received a reply? Using Outlook 7
T Macro to move reply and original message to folder Outlook VBA and Custom Forms 6
A Is there an ID field you can use to pair a reply to the sent email? Outlook VBA and Custom Forms 4
W Reply to email Using Outlook 4
A Edit attachment Save and Reply Outlook VBA and Custom Forms 0
L Macro/VBA to Reply All, with the original attachments Outlook VBA and Custom Forms 2
S Outlook Macro to move reply mail based on the key word in the subjectline Outlook VBA and Custom Forms 0
diver864 vba for a rule to automatically accept meeting requests with 'vacation' in subject, change to all-day event, change to free, don't send reply Outlook VBA and Custom Forms 1
B Adding signature to bottom of VBA reply email Outlook VBA and Custom Forms 1
C UDFs Reply vs Forward Outlook VBA and Custom Forms 3
ThinkToday Calculate reply time of outlook mail Using Outlook 1
W Replyin to the reply-to email address Outlook VBA and Custom Forms 0
D Reply with a template loose the sender's embedded image Outlook VBA and Custom Forms 0
R List folders in a combo box + select folder + move emails from inbox to that folder + reply to that email Outlook VBA and Custom Forms 1
J Outlook Reply > From > Other Email Address... > Address Not Showing in Sent Items... From Email Outlook VBA and Custom Forms 0
E reply Using Outlook 0
Healy Consultants Macro to remove inside organization distribution list email address when reply to all recepients Outlook VBA and Custom Forms 0
B resend if no reply and send an automatic reminder Outlook VBA and Custom Forms 0
evdbogaard Reply with only last message cited Using Outlook 1
B Reply and replyall macro is not working Outlook VBA and Custom Forms 1
mctabish Setting "Reply To" based on inbox Outlook VBA and Custom Forms 2
Rupert Dragwater Deleted email address keeps showing up in reply Using Outlook 12
B When working on emails in a certain folder, when I hit reply or reply all, I would like it re always reply all and add an email address to send to Outlook VBA and Custom Forms 3
R How Do I insert images in and Auto Reply Using Outlook 3
D Disable or hide "reply" and "reply to all" and "forward" in email from access vba Outlook VBA and Custom Forms 1
broadbander Needing help with reply/reply all while keeping attachments and adding a new CC recipient. Outlook VBA and Custom Forms 5
O On click,I want to change subject line of selected mail and then reply to particular email and move Using Outlook 3
J VBA Run When Reply Outlook VBA and Custom Forms 4
D Font in Reply is much larger than normal, how to reset ...? Using Outlook 4
K add pdf to every reply or forward Outlook VBA and Custom Forms 1
A VB to "reply all" email items stored in a folder of outlook with adding a new message Outlook VBA and Custom Forms 0
K Extract email address from body and auto-reply outlook Using Outlook 1
T In-line reply style in Outlook Outlook VBA and Custom Forms 20
Vijay Reply all by attachment name Using Outlook 10
N Lookup Value From Excel and Reply With Matching Value Using Outlook 0
G Outlook 2016: reply icon not showing when replied from mobile Using Outlook 3
J Remove extra line above signature in reply Outlook VBA and Custom Forms 5
ashcosta2 Auto Reply rule based on speficied time Outlook VBA and Custom Forms 0
C Outlook Attachment List in Reply Header Using Outlook 3
D Reply Problem with Outlook.com account Using Outlook.com accounts in Outlook 0
H send reminder if no reply received on first or original email using macro Using Outlook 2
Diane Poremsky Reply to All Includes My Address Using Outlook 0

Similar threads

Back
Top