Reply to an Email With a Template

This sample explains the basics for replying with a template.

Last modified: 2006/01/19 | Accessed: 84.096  | #9
◀ Previous sample Next sample ▶
Determine the "identity" of your emails. Set with SAM the sender and the folder folder for sent items with the help of rules.

At work we get many emails that could be responded with a template. It's evident that you can save a lot of time if there's a template you can send. This sample shows how that works. You can either reply to the opened email or to the selected one in the folder.

The following first function determines the subject and the message. The main function that will create the reply will be called with these values. If you want to use several templates this way, simply copy the Reply_1 function, and give each function any unique name.

(There is a similar function that uses templates stored in the Drafts folder)

tip  How to add macros to Outlook
Public Sub Reply_1()
  Dim Subject As String, Msg As String

  Subject = "Re: "
  Msg = "Sample Message 1"

  ReplyMail Subject, Msg
End Sub
Reporter Reporter
VBOffice Reporter is an easy to use tool for data analysis and reporting in Outlook. A single click, for instance, allows you to see the number of hours planned for meetings the next month.

The following function is necessary only once. This one creates the reply with the passed values for the subject and the message.

Private Sub ReplyMail(Subject As String, Msg As String)
  Dim obj As Object
  Dim oReply As Outlook.MailItem

  If TypeOf Application.ActiveWindow Is Outlook.Inspector Then
    Set obj = Application.ActiveInspector.CurrentItem
    With Application.ActiveExplorer.Selection
      If .Count Then
        Set obj = .Item(1)
      End If
    End With
  End If

  If obj Is Nothing Then Exit Sub

  If TypeOf obj Is Outlook.MailItem Then
    Set oReply = obj.Reply
    If InStr(1, oReply.Subject, Subject, vbTextCompare) = 0 Then
      oReply.Subject = Subject & obj.Subject
      oReply.Body = Msg & vbCRLF & vbCRLF & oReply.Body
    End If
  End If
End Sub
Category-Manager Category-Manager
With Category-Manager you can group your Outlook categories, share them with other users, filter a folder by category, automatically categorize new emails, and more. You can use the Addin even for IMAP.
email  Send a message