How to use Outlook template in MS Access SendObject maco

Posted on 2014-08-27
Last Modified: 2015-03-17
Because the SendObject's message text argument is limited to 255 characters, I would like to utilize the template argument; however, when I enter the path for my Outlook template file ("S:\MainFolder\SubFolder\Untitled.oft"), the macro halts. What am I doing wrong? Much thanks in advance!
Question by:jaguar5554
    LVL 47

    Accepted Solution


    pls try
    Sub macro2()
    Dim oOutlook As Object
    Dim oMailItem As Object
    Set oOutlook = CreateObject("Outlook.Application")
    Set oMailItem = oOutlook.CreateItem(0)
    Set oMailItem = oOutlook.CreateItemFromTemplate("S:\MainFolder\SubFolder\Untitled.oft")
    strEmail = ""
    strSubject = "Test"
    strBody = "Test Body"
    oMailItem.To = strEmail
    oMailItem.Subject = strSubject
    oMailItem.Body = strBody
    oMailItem.Display ' Or
    Set oOutlook = Nothing
    Set oMailItem = Nothing
    End Sub

    Open in new window

    LVL 84
    To be clear: You cannot define a Template when you use SendObject. You must use Outlook Automation, as RGonzo has illustrated.

    I find that using vbMAPI from to be the simplest and most reliable way to handle things like this. Costs about $90 USD, but is well worth the cost. Note I have no affiliation with the company except as a satisfied client.

    Author Comment

    Hello, I must have missed the expert responses to my inquiry -- my sincere apologies! Although we worked around the issue and no longer require to send object -- I will test the suggestion in case the need comes up in a different or new project. Thanks much!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
    Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
    Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
    In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now