+ Reply to Thread
Results 1 to 6 of 6

VBA issue: file not attaching in email

  1. #1
    Forum Contributor
    Join Date
    11-26-2010
    Location
    usa
    MS-Off Ver
    Office 365
    Posts
    1,233

    VBA issue: file not attaching in email

    Hi

    I have my code, where it saves a file based on username, in a specific folder, and then creates an email and attaches the filtered version of the file so i can send the email out.

    this is my original macro:
    Please Login or Register  to view this content.

    I made some changes to my macro, added columns etc, and revise the code. for some odd reason, it's not attaching the file when it creates the email. it's creating the email in outlook perfectly, just not attaching the file anymore. Its showing the error as "error attaching file:[listed path] ---- see thread below for vba that is not working
    Last edited by jw01; 08-05-2024 at 04:54 PM.

  2. #2
    Forum Contributor
    Join Date
    11-26-2010
    Location
    usa
    MS-Off Ver
    Office 365
    Posts
    1,233

    Re: VBA issue: file not attaching in email

    below is the updated macro that is NOT attaching the file. CAN SOMEONE PLS ASSIST?
    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    11-26-2010
    Location
    usa
    MS-Off Ver
    Office 365
    Posts
    1,233

    Re: VBA issue: file not attaching in email

    any thoughts on this guys?

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,487

    Re: VBA issue: file not attaching in email

    No idea off the top of my head. I would try commenting out all the error handling and/or stepping through the code to see a) if it crashes and b) if it misses out any section of the code.


    Fast answers need visual help. Please read the yellow banner at the top of this page on how to attach a file and a mocked up solution.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  5. #5
    Forum Expert
    Join Date
    08-17-2007
    Location
    Poland
    Posts
    2,542

    Re: VBA issue: file not attaching in email

    Try uncommenting the line with Send at the end of the 'emailer' procedure. With this setting, will the email be sent with an attachment?

    Artik

  6. #6
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,487

    Re: VBA issue: file not attaching in email

    In the original code, you set the file name early on to: fname = "C:\Users\john.smith\xx\Desktop\FP&A\Allocations\Test\Consolidated IES.xlsx"

    In the failing code, you set the file name much later on: fname = "C:\Users\john.smith\xx\Desktop\Test\Consolidated IES_" & recipientName & ".xlsx"
    where recipientName has been processed.

    I'm guessing that line of code is either not executed, or the sanitisation has left something that shouldn't be there, or the code that attaches the file fails or isn't executed. Lots of options.

    IMO, the only way to diagnose this is to switch off error handling and step through the code, checking the variabes and the route through the code.

+ 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. Block email address from attaching file
    By Dbroek in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-09-2023, 11:02 AM
  2. [SOLVED] Issue with attaching files to an email through VBA
    By Valont in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-12-2022, 07:22 AM
  3. [SOLVED] How to prevent VBA from attaching a particular file when it generates email
    By bdouglas1011 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-17-2018, 07:41 PM
  4. Attaching an embedded PDF file in my worksheet to a new email
    By AnthonyGFS in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-14-2017, 04:24 AM
  5. [SOLVED] VBA code exporting to PDF but not attaching the file to the email.
    By michelle 1 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 08-24-2016, 03:11 AM
  6. Email (outlook) recipients attaching specific file name.
    By monkeypants in forum Outlook Formatting & Functions
    Replies: 1
    Last Post: 05-13-2015, 07:18 PM
  7. Attaching One Worksheet of a File to Email
    By MLCall in forum Excel General
    Replies: 0
    Last Post: 01-17-2012, 12:51 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