Skip to content

Instantly share code, notes, and snippets.

@karoltheguy
Last active August 29, 2015 14:17
Show Gist options
  • Save karoltheguy/93019f6b6da912a616da to your computer and use it in GitHub Desktop.
Save karoltheguy/93019f6b6da912a616da to your computer and use it in GitHub Desktop.
Mass Auto Reply Outlook Macro
Sub SendReply(Item As Outlook.MailItem)
Dim strRecip As String
Dim Recipient As Outlook.Recipient
Dim objMsg As MailItem
'Save a template with a the content you want to reply and the CC addresses if needed, nothing else.
Set objMsg = Application.CreateItemFromTemplate("path of template .oft")
'Add sender of original email
'Optional IF if there is a particular sender you never want to reply back
If Item.SenderName <> "name(Item.SenderName) or address(Item.SenderEmailAddress) if not an exchange account" Then
objMsg.Recipients.Add Item.SenderEmailAddress
End If
'get CC list
For Each Recipient In Item.Recipients
If Recipient.Address <> Item.SenderEmailAddress Then
strRecip = Recipient.Address & ";" & strRecip
End If
Next Recipient
objMsg.CC = strRecip
' Set From Field if something than normal account
objMsg.SentOnBehalfOfName = "some address"
' Copy the original message subject
objMsg.Subject = "RE: " & Item.Subject
' Copy previous body msg with header
objMsg.HTMLBody = objMsg.HTMLBody & "<DIV dir=ltr lang=en-us class=OutlookMessageHeader align=left>" & _
"<HR tabIndex=-1>" & "<b>From: </b>" & Item.SenderName & "<br><b>Sent: </b>" & Item.ReceivedTime & _
"<br><b>To: </b>" & Item.To & "<br><b>Subject: </b>" & Item.Subject & "<br><br>" & Item.HTMLBody
objMsg.Send
End Sub
@karoltheguy
Copy link
Author

This is to create a mass auto reply from an Outlook Macro which would be called from a rule

Set a blank rule (Check messages when they arrive) and then set to "run a script"
Set the script to be SendReply

To make it work, you only need to go in the directory that the emails are, go back in the "Rules and Alerts" then go in "Run Rules now..." and select the new rule you just made.
This will automatically reply to all emails from the choosen folder

Be careful to not check this rule in the "Rules and Alerts" window, otherwise it will reply automatically to all the received emails.

There is a few things to set up as indicated by the comments in the code.

Enjoy!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment