Send an Email Template

This sends not the draft itself but a the copy of it so you can reuse the draft.

Last modified: 2007/02/22 | Accessed: 33.682  | #44
◀ Previous sample Next sample ▶
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.

This sample demonstrates how to find an item by its Subject. If found, a copy will be created an displayed. You can edit and send that copy without changing the original draft.

Add a subfolder to the Draft folder, call it My Templates and save your templates there where they won't bother you. The template itself is called 'Template 1'. Replace it by the subject of your template. You can call the macro by pressing ALT+F8. If you want to use several templates this way, simply copy the Draft_1 function, and give each function any unique name.

(Here is a similar function)

tip  How to add macros to Outlook
Private Const TemplateFolder As String = "My Templates"

Public Sub Draft_1()
  LoadTemplate "Template 1"
End Sub

Private Sub LoadTemplate(Name As String)
  Dim Ns As Outlook.NameSpace
  Dim Folder As Outlook.MAPIFolder
  Dim Mail As Outlook.MailItem

  Set Ns = Application.GetNamespace("MAPI")
  Set Folder = Ns.GetDefaultFolder(olFolderDrafts)
  Set Folder = Folder.Folders(TemplateFolder)
  Set Mail = LoadTemplate_Ex(Folder.Items, Name)
  If Not Mail Is Nothing Then
    MsgBox "No template with the subject: '" & Name & "' found"
  End If
End Sub

Private Function LoadTemplate_Ex(Items As Outlook.Items, Name As String) As Outlook.MailItem
  On Error Resume Next
  Dim Mail As Outlook.MailItem
  Set Mail = Items.Find("[subject]=" & Chr(34) & Name & Chr(34))
  If Not Mail Is Nothing Then
    Set GetTemplate = Mail.Copy
  End If
End Function
Category-Manager Category-Manager
Access the master category list in the blink of an eye, share your color categories in a network, get a reminder service, and more.
email  Send a message