Configure Outlook to generate email from a template on reminder

If you want to send out email using Outlook in a particular format at a particular time, just make use of templates & reminders and configure the following macro to integrate them.

a) Create an outlook template just like the mail you want to send and save it at a convenient location. To learn how to create an outlook template, read this:

b) Create a new function in VBA editor to generate an email from the template.

  1. Open up the VB editor [Alt+F11 in Office 2007 or Tools → Macro → Visual Basic Editor]
  2. Under ThisOutlookSession add the following function:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    Sub createMailFromTemplate()
      Set oApp = CreateObject("Outlook.Application")
      'Give path of the template that was created.
      templateFile = "D:\data\myTemplate.oft"
      Set oMail = oApp.CreateItemFromTemplate(templateFile)
      'Modify the subject
      oMail.Subject = "Daily data for " & Format(Date, "dd.mm.yyyy")
      oMail.Display
    End Sub

c) Finally, add a function to call createMailFromTemplate() [created above] when the reminder pops-up. To learn how to create an Outlook reminder, read this:

  1. Open up the VB editor.
  2. Under ThisOutlookSession add the following function:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    Private Sub Application_Reminder(ByVal Item As Object)
      Dim strSubject As String
      strSubject = Item.Subject
      Dim count As Long
      ' Check the subject of the reminder.
      count = InStr(1, strSubject, "daily data mail")
      If count > 0 Then
        Call createMailFromTemplate
      End If
    End Sub
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s