+ Reply to Thread
Results 1 to 6 of 6

Excel workbook email macro not working

Hybrid View

  1. #1
    Registered User
    Join Date
    07-28-2010
    Location
    london, england
    MS-Off Ver
    Excel 2007
    Posts
    91

    Excel workbook email macro not working

    Hi all,

    I have the following commonly used macro to email a workbook via outlook:

    Sub Send_Email_Current_Workbook()
    
    ThisWorkbook.Save
    
    Dim OutApp As Object
    Dim OutMail As Object
    
    Set OutApp = CreateObject("Outlook.Application")
    OutApp.Session.Logon
    Set OutMail = OutApp.CreateItem(0)
    
    On Error Resume Next
    With OutMail
    .To "jfarr3ll@XX.com"
    .Subject = "Timelines Spreadsheet Updated - Subject"
    .Body = "Please see attached the updated Timelines Spreadsheet for your reference"
    .Attachments.Add ActiveWorkbook.FullName
    .Send
    End With
    On Error GoTo 0
    Set OutMail = Nothing
    Set OutApp = Nothing
    MsgBox "email sent"
    End Sub
    however it has stopped working for me and I'm wondering if anyone has any ideas why this might be?

    The code worked fine a few weeks ago, but now goes through the process to the end (msgbox pops up), but doesn't seem to send any email.
    Last edited by j.farr3ll; 04-16-2014 at 03:33 AM.

  2. #2
    Forum Expert
    Join Date
    06-25-2009
    Location
    Sofia, Bulgaria, EU
    MS-Off Ver
    Excel 2003-2013
    Posts
    1,290

    Re: Excel workbook email macro not working

    Hi, comment out On Error Resume Next statement and see what is the error that will be raised
    If you are pleased with a member's answer then use the Star icon to rate it.

  3. #3
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,609

    Re: Excel workbook email macro not working

    Perhaps you could use this add-in for mailing? Very versatile and works well

  4. #4
    Registered User
    Join Date
    07-28-2010
    Location
    london, england
    MS-Off Ver
    Excel 2007
    Posts
    91

    Re: Excel workbook email macro not working

    I have found the problem. The line of code
    .To "jfarr3ll@XX.com"
    should have read
    .To = "jfarr3ll@XX.com"
    Just a typing error.

    Thanks everyone for looking and buran for pointing me in the right direction.

  5. #5
    Registered User
    Join Date
    07-28-2010
    Location
    london, england
    MS-Off Ver
    Excel 2007
    Posts
    91

    Re: Excel workbook email macro not working

    Hi buran,

    I am getting the error on the following line:

    .To "jfarr3ll@XX.com"
    the error is:

    Run-time error '-2147352567 (80020009)':
    The object does not support this method

  6. #6
    Forum Expert
    Join Date
    06-25-2009
    Location
    Sofia, Bulgaria, EU
    MS-Off Ver
    Excel 2003-2013
    Posts
    1,290

    Re: Excel workbook email macro not working

    It should be
    .To = "jfarr3ll@XX.com"
    Actually I don't know how I didn't see it right from the beginning.

+ 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. Macro to attach excel pdf to email not working
    By dantray02 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-25-2014, 11:30 AM
  2. Macro to PDF a sheet in workbook and email (outlook) to an email address in a cell
    By paul_sykes00 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 12-17-2012, 12:54 AM
  3. [SOLVED] Email Workbook macro not working with Windows 7
    By Lewej23 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-22-2012, 06:52 PM
  4. [SOLVED] Email Workbook macro not working with Windows 7
    By Lewej23 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-21-2012, 03:22 PM
  5. Replies: 4
    Last Post: 06-02-2012, 01:49 PM

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