Macro to Reply to Emails w/ Template

John Simmons

New Member
Outlook version
Outlook 365 64 bit
Email Account
Exchange Server
Hello,

I am trying to create a macro to reply to emails with a template. When I use the macro below (which I found online), it puts the sender's name (not email address) in the reply To: box. This is frustrating because then I have to delete the name and copy and paste the actual email address. I tried changing the line with replyEmail.To = origEmail.Sender to replyEmail.To=origEmail.SenderEmailAddress, but then I just got a long string of letters and numbers in the reply To: box when I ran the macro. Any thoughts? Thank you!

Sub MacroName()

Dim origEmail As MailItem
Dim replyEmail As MailItem

Set origEmail = Application.ActiveWindow.Selection.Item(1)
Set replyEmail = Application.CreateItemFromTemplate("C:\path\templatename.oft")

replyEmail.To = origEmail.Sender
replyEmail.CC = origEmail.CC
replyEmail.Subject = origEmail.Subject

replyEmail.HTMLBody = replyEmail.HTMLBody & origEmail.Reply.HTMLBody
replyEmail.Display

End Sub
 

John Simmons

New Member
Outlook version
Outlook 365 64 bit
Email Account
Exchange Server
Thanks! OK, I think I see the problem now. SenderEmailAddress works for external emails, but not internal ones in my organization. If I use the macro on an email from someone within my organization, it inserts a weird string of letters and numbers in the reply To: field. But it works fine for external emails, which is primarily what I will be using this macro for. Thanks again!

John
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
You can use an IF statement to choose -

if instr(1, origEmail.senderemailaddress, "@") >0 then
' use sender address
replyEmail.To = origEmail.SenderEmailAddress
else
'use sender
replyEmail.To = origEmail.Sender
end if
 
Last edited:
Similar threads
Thread starter Title Forum Replies Date
S Outlook 2003: Help with setting up a macro to reply to selected emails Using Outlook 2
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
T Macro to move reply and original message to folder Outlook VBA and Custom Forms 6
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
Healy Consultants Macro to remove inside organization distribution list email address when reply to all recepients Outlook VBA and Custom Forms 0
B Reply and replyall macro is not working Outlook VBA and Custom Forms 1
H send reminder if no reply received on first or original email using macro Using Outlook 2
S Outlook Macro Reply to a message Outlook VBA and Custom Forms 1
reza Macro to automatic reply using orignal mail Outlook VBA and Custom Forms 10
S Macro for Reply All in 2013 Outlook Outlook VBA and Custom Forms 10
B Auto reply using macro include original email Using Outlook 4
L Outlook 2007 Macro Reply to E-mail Using Outlook 16
M Reply Macro using O365 Connected Account Using Outlook 2
A Macro in Outlook for auto-reply Using Outlook 3
M Auto-reply with macro whether logged in to outlook or not Outlook VBA and Custom Forms 2
M Use Macro to change account settings Outlook VBA and Custom Forms 1
C Outlook - Macro to block senders domain - Macro Fix Outlook VBA and Custom Forms 2
Witzker Outlook 2019 Macro to seach in all contact Folders for marked Email Adress Outlook VBA and Custom Forms 1
S macro error 4605 Outlook VBA and Custom Forms 0
A Macro Mail Alert Using Outlook 4
J Outlook 365 Outlook Macro to Sort emails by column "Received" to view the latest email received Outlook VBA and Custom Forms 0
J Macro to send email as alias Outlook VBA and Custom Forms 0
M Outlook Macro to save as Email with a file name format : Date_Timestamp_Sender initial_Email subject Outlook VBA and Custom Forms 0
Witzker Outlook 2019 Macro GoTo user defined search folder Outlook VBA and Custom Forms 7
D Outlook 2016 Creating an outlook Macro to select and approve Outlook VBA and Custom Forms 0
Witzker Outlook 2019 Macro to send an Email Template from User Defined Contact Form Outlook VBA and Custom Forms 0
Witzker Outlook 2019 Macro to check Cursor & Focus position Outlook VBA and Custom Forms 8
V Macro to mark email with a Category Outlook VBA and Custom Forms 4
M Outlook 2019 Macro not working Outlook VBA and Custom Forms 0
S Outlook 365 Help me create a Macro to make some received emails into tasks? Outlook VBA and Custom Forms 1
Geldner Send / Receive a particular group via macro or single keypress Using Outlook 1
D Auto Remove [EXTERNAL] from subject - Issue with Macro Using Outlook 21
V Macro to count flagged messages? Using Outlook 2
sophievldn Looking for a macro that moves completed items from subfolders to other subfolder Outlook VBA and Custom Forms 7
S Outlook Macro for [Date][Subject] Using Outlook 1
E Outlook - Macro - send list of Tasks which are not finished Outlook VBA and Custom Forms 3
E Macro to block senders domain Outlook VBA and Custom Forms 1
D VBA Macro to Print and Save email to network location Outlook VBA and Custom Forms 1
N VBA Macro To Save Emails Outlook VBA and Custom Forms 1
Witzker Outlook 2019 Macro to answer a mail with attachments Outlook VBA and Custom Forms 2
J Macro to Insert a Calendar Outlook VBA and Custom Forms 8
W Macro to Filter Based on Latest Email Outlook VBA and Custom Forms 6
D Autosort macro for items in a view Outlook VBA and Custom Forms 2
S HTML to Plain Text Macro - Help Outlook VBA and Custom Forms 1
A Macro to file emails into subfolder based on subject line Outlook VBA and Custom Forms 1
N Help creating a VBA macro with conditional formatting to change the font color of all external emails to red Outlook VBA and Custom Forms 5
S Visual indicator of a certain property or to show a macro toggle Outlook VBA and Custom Forms 2
L Modifying VBA script to delay running macro Outlook VBA and Custom Forms 3

Similar threads

Top