VBOffice

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: 27.922  | #44
◀ Previous sample Next sample ▶
ReplyAll ReplyAll
ReplyAll alerts you before unintentionally replying all, or if you are a confidential BCC recipient of the e-mail.

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

Here the template 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
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 Mail = LoadTemplate_Ex(Folder.Items, Name)
  If Not Mail Is Nothing Then
    Mail.Display
  Else
    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
SAM SAM
SAM automatically sets the sending account, or sender address, and folder for sent items based on several criteria.
email  Send a message