Results 1 to 5 of 5

Problem with VBA code to attach file to email using a pre saved Outlook template

Threaded View

Wooltrain Problem with VBA code to... 04-12-2017, 03:11 AM
Richard Buttrey Re: Problem with VBA code to... 04-12-2017, 04:19 AM
Wooltrain Re: Problem with VBA code to... 04-12-2017, 07:31 PM
aarona Re: Problem with VBA code to... 04-12-2017, 08:14 PM
Wooltrain Re: Problem with VBA code to... 04-12-2017, 08:28 PM
  1. #1
    Registered User
    Join Date
    07-22-2013
    Location
    Sydney, NSW
    MS-Off Ver
    Excel 2007
    Posts
    5

    Problem with VBA code to attach file to email using a pre saved Outlook template

    Hello,

    Forgive me for being somewhat of a novice with macro coding but I have a code that works for me on my computer but does not work when my colleagues attempt to do so on theirs.
    Background: I have an inventory update file that I prepare for my colleagues each day. Many of the functions that create the update file are controlled by macros. To make the update and distribution of the file as quick and simple as possible I wrote a macro to attach the file to an Outlook template. The Outlook template contains a whole lot of information in the body and all the email addresses of the recipients. I attached that macro to a command button on the form.
    It works great for me. I click the command button and everything works.
    But when I am not in the office, the update function and distribution needs to be handled by someone else. For that reason, I stored the Outlook template (otf file) on one of our network drives.

    However, when my colleagues attempt to run that macro on their computer it does not send the email.
    Here is the code:

    Dim myOutlook As Object
        Dim myMailItem As Object
    
        With Application
            .ScreenUpdating = False
            .EnableEvents = False
        End With
    
        Set otlApp = CreateObject("Outlook.Application")
        Set otlNewMail = otlApp.CreateItemFromTemplate("H:\Operations Supply Chain\2. OPERATIONS\Inventory Management\1. Available Inventory Report\Temp\Available Inventory Report.oft")
            
            On Error Resume Next
                With otlNewMail
                    .Attachments.Add ("H:\Operations Supply Chain\2. OPERATIONS\Inventory Management\1. Available Inventory Report\Temp\Copy of Available Inventory Report.xls")
                    .Send
                End With
                On Error GoTo 0
                
        Set otlNewMail = Nothing
        Set otlApp = Nothing
    Any help with what I'm doing wrong here would be greatly appreciated.
    Thank you.
    Last edited by Wooltrain; 04-12-2017 at 07:28 PM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. attach file in an outlook email from specific folder
    By 9599lorenzo in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-19-2017, 07:07 AM
  2. Attach last saved file outlook/add this to quick step in Outlook
    By Nravota in forum Outlook Programming / VBA / Macros
    Replies: 0
    Last Post: 06-25-2015, 06:25 AM
  3. Code to attach file paths to email
    By petaaalouise in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-22-2015, 02:54 AM
  4. [SOLVED] Macro to attach an additional file to and outlook email
    By Groovicles in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-18-2014, 01:27 PM
  5. Email merge from excel merge file using pre-saved word template
    By d_max_c in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-17-2014, 12:33 PM
  6. [SOLVED] Email Macro to attach a non active worksheet to outlook email
    By mickgibbons1 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-21-2013, 08:38 PM
  7. Code to attach a sheet as an Outlook email attachment
    By rlsublime in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-30-2011, 11:32 AM

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