+ Reply to Thread
Results 1 to 2 of 2

Adding body to email via VBA for an outlook template

Hybrid View

  1. #1
    Registered User
    Join Date
    06-07-2012
    Location
    Australia
    MS-Off Ver
    Excel 2007
    Posts
    8

    Adding body to email via VBA for an outlook template

    Hi All,

    Im using a macro that links attaches an active workbook to a specific outlook template. However, because im using the template, any time I try to add body to the template via code, it overwrites the template and the email just goes back to a normal one. Please note that within the body I would like to reference cells, hence it would need to be dynamic.

    Is there any way to be able to add text to the email template body? Here is the code im working with:

    Sub Mail_Workbook_1()
       Dim OL              As Object
        Dim EmailItem       As Object
        Dim Wb              As Workbook
         
        Application.ScreenUpdating = False
        Set OL = CreateObject("Outlook.Application")
        Set EmailItem = OL.CreateItemfromtemplate("C:\Users\blah\email_template.msg")
        Set Wb = ActiveWorkbook
        Wb.Save
        With EmailItem
            .Subject = "blah blah" & Worksheets(2).Range("c2") & " - " & Worksheets(2).Range("c4")
            .To = Sheets(2).Range("C5").Value
            .CC = Sheets(2).Range("C6").Value
            .BCC = "blahblah@blah.com"
            .Importance = olImportanceHigh 'Or olImprotanceHigh Or olImprotanceLow
            .Attachments.Add Wb.FullName
            .Save
        End With
         
        Application.ScreenUpdating = True
         
        Set Wb = Nothing
        Set OL = Nothing
        Set EmailItem = Nothing
        Set olMailItem = Nothing
         
    End Sub
    Thanks!

    Tee
    Last edited by teekayy; 06-07-2012 at 08:39 AM.

  2. #2
    Registered User
    Join Date
    06-07-2012
    Location
    Australia
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Adding body to email via VBA for an outlook template

    bump?

    thanks guys!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1