+ Reply to Thread
Results 1 to 3 of 3

VBA Using Excel to Attach file to Email

  1. #1
    Registered User
    Join Date
    03-21-2013
    Location
    England
    MS-Off Ver
    2007
    Posts
    21

    VBA Using Excel to Attach file to Email

    Sub Mail_Workbook_1()
    ' Works in Excel 2000, Excel 2002, Excel 2003, Excel 2007, Excel 2010, Outlook 2000, Outlook 2002, Outlook 2003, Outlook 2007, Outlook 2010.
    ' This example sends the last saved version of the Activeworkbook object .
    Dim OutApp As Object
    Dim OutMail As Object

    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(0)

    On Error Resume Next
    ' Change the mail address and subject in the macro before you run it.
    With OutMail
    .To = ""
    .CC = ""
    .BCC = ""
    .Subject = "TITLE"
    .Body = "CONTENT"
    .Attachments.Add ("*FILEPATH*")

    .send
    End With

    Set OutMail = Nothing
    Set OutApp = Nothing

    End Sub
    This comfortably sends the email with or without the file attached. What I want is the macro to stop if the file is not locatable or attached.

    Information - File name and location will never change - It will get added during the week to be sent every Monday.

    This will be run from a VBS script which also works, so set to scheduled task meaning the user shouldn't have to click anything to cancel the email.

    What would be ideal is if the macro was cancelled due to no file, they get an email announcing the process failed.

    Please Please help as everything I've tried has failed. Thanks in advance.

  2. #2
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,125

    Re: VBA Using Excel to Attach file to Email

    Please Login or Register  to view this content.
    David
    (*) Reputation points appreciated.

  3. #3
    Registered User
    Join Date
    03-21-2013
    Location
    England
    MS-Off Ver
    2007
    Posts
    21

    Re: VBA Using Excel to Attach file to Email

    Dude I love you. Thank you so much

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. I need VBA to save file and attach file to email based on conditional statements
    By jcrowe31 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-01-2014, 09:41 AM
  2. [SOLVED] Create an email in Excel and attach the file as a PDF
    By MissDB in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 03-21-2014, 09:50 AM
  3. [SOLVED] Trying to create a .pdf and attach it to email, but get .xls file instead
    By sbrnard in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-19-2013, 01:21 PM
  4. [SOLVED] Attach a file and email it using Excel.
    By Paul Morgan in forum Outlook Programming / VBA / Macros
    Replies: 2
    Last Post: 11-18-2012, 09:32 AM
  5. Email workbook AND attach a separate file to the email
    By sgreni in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-15-2009, 06:48 PM

Tags for this Thread

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