Send an Email Template

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

Last modified: 2017/02/25 | Accessed: 87.135  | #44
◀ Previous sample Next sample ▶
OLKeeper OLKeeper
OLKeeper reliably prevents users from closing their Outlook window and thus possibly missing reminders or e-mails.

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 LoadTemplate_Ex = Mail.Copy
  End If
End Function
Determine the "identity" of your emails. Set with SAM the sender and the folder folder for sent items with the help of rules.
email  Send a message