+ Reply to Thread
Results 1 to 10 of 10

VBA to add attachments when sending emails.

  1. #1
    Registered User
    Join Date
    10-19-2023
    Location
    miami fl
    MS-Off Ver
    not sure
    Posts
    6

    Exclamation VBA to add attachments when sending emails.

    Hello,

    I am currently working with the below code to send mass invoicing emails. The issue is that I have over 1,000 clients and each client may have 1 - 7 pending invoices.

    I would like to be able to send mass personalized emails with as little or as many attachments as needed(it wont exceed 10).
    2 attachments should be included in every single email regardless of the amount of invoices. These contain payment methods.

    Is there an If statement or something I can use to say send each email regardless if its 2 or 6 attachments.

    Currently I have to filter clients with only one invoice and send, then filter ones with 2 invoices and send, etc.

    Any help is so appreciated!!! Thanks

    Please Login or Register  to view this content.
    Admin note: Please take the time to review our rules. There aren't many, and they are all important. Our guidelines recommend code tags. I have added them for you this time because you are a new member. --6StringJazzer
    Last edited by 6StringJazzer; 11-14-2023 at 06:19 PM.

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: VBA to add attachments when sending emails.

    Please open Excel, go to File > Account, and find your version number. Then update your profile. Otherwise you could get answers that won't work with your version of Excel.

    Excel version.jpg
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: VBA to add attachments when sending emails.

    It's not too hard to do that but you have to explain what is your logic for what attachments to include. Your code gives no clue beyond the first two. Even with the filtering you describe I don't see how you are sending out the additional invoices.

  4. #4
    Registered User
    Join Date
    10-19-2023
    Location
    miami fl
    MS-Off Ver
    not sure
    Posts
    6

    Re: VBA to add attachments when sending emails.

    Hi Jeff,
    Thanks for the response!
    I've updated to version 2310.
    As of now I am not sending additional invoices, I only use this code to send emails with one invoice attached, the rest I do by hand.
    I dont know how to write code or anything, I just tweaked this code slightly from a YouTube video.

    Id like to be able to attach as little or as many invoices and send them all at once.

    Below attachments should be included in every single email regardless of the amount of invoices as they are payment methods.

    Attachments.Add "C:\Users\yshriki\OneDrive - GLSC & Company\Desktop\Invoices\Credit_Card_Authorization_Form_!.pdf"
    Attachments.Add "C:\Users\yshriki\OneDrive - GLSC & Company\Desktop\Invoices\Wire Transfer Instructions.pdf"

    I have one column(D) labeled file where I attach the invoice pdf, Id like to have multiple columns file 2(E), file 3(F), file 4(G) etc where i can upload more invoices that need to be attached.

    The problem is when I add code to attach from these columns it does not run because some cells in those columns are empty. I dont know how to write code that could resolve this.

    Sincerely,

  5. #5
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: VBA to add attachments when sending emails.

    From what you are describing my gut instinct is to do this, but obviously I can't test it without your file.

    This will start looking for additional attachments in column E and keep going until it reaches a blank column (for that row). You can have as many as you want until you use up all the columns.
    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    10-19-2023
    Location
    miami fl
    MS-Off Ver
    not sure
    Posts
    6

    Re: VBA to add attachments when sending emails.

    Hey Jeff, Thank you for taking time to edit the code!

    I just tested this and unfortunately it gave me an error.

    .Attachments.Add "C:\Users\yshriki\OneDrive - GLSC & Company\Desktop\Invoices" & ThisWorkbook.Sheets("Client_Data").Cells(introw, Col)

    This portion was highlighted as an error that I need to debug. The error reads "the remote server machine does not exist or is unavailable" run time error "462"

    The code did send my first email(row 2) but it only contained one attachment on column D, the next row(3) has 2 attachments column D and E, row 4 has 3 attachments column D,E,F and lastly row 4 has attachments on column D,E,F,G.

    to explain my set up, column A has the client ID name, column B has the email ID, Column C has the amount owed, and the rest of the columns are for each invoice per client.

    I also had another question, is it possible to list multiple emails in Column B, in case I want to send the email to 3 people at once for example?


    I hope I'm not a bother, I really do appreciate all the help. Thank you.

  7. #7
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: VBA to add attachments when sending emails.

    You omitted the slash

    Please Login or Register  to view this content.
    You can list multiple emails, but the way the code will handle depends on how you list them. I'm assuming you want all the email addresses in one cell? Please give an example.

  8. #8
    Registered User
    Join Date
    10-19-2023
    Location
    miami fl
    MS-Off Ver
    not sure
    Posts
    6

    Re: VBA to add attachments when sending emails.

    thank you for catching my error.
    yes i would like the option to add more than one email in the same cell, and in a separate column have the option top add an email as a CC.

    SIncerely,

  9. #9
    Registered User
    Join Date
    10-19-2023
    Location
    miami fl
    MS-Off Ver
    not sure
    Posts
    6

    Re: VBA to add attachments when sending emails.

    i still have an error with this line.. not sure why.

    .Attachments.Add "C:\Users\yshriki\OneDrive - GLSC & Company\Desktop\Invoices" & ThisWorkbook.Sheets("Client_Data").Cells(introw, Col)

  10. #10
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: VBA to add attachments when sending emails.

    Quote Originally Posted by masterlotus View Post
    i still have an error with this line.. not sure why.
    I answered this in post #7.

+ 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. Auto PDF new emails & attachments?
    By MattHamby in forum Outlook Formatting & Functions
    Replies: 1
    Last Post: 11-20-2018, 08:31 AM
  2. [SOLVED] Macro in Excel to send emails in outlook sending hyperlinks but need attachments
    By L_Misty in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-04-2017, 02:19 PM
  3. Send multiple emails with different attachments if attachments found
    By AnkitJain in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-05-2015, 05:35 AM
  4. Attachments when sending bulk emails
    By bruskieza in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-17-2015, 10:09 AM
  5. [SOLVED] Sending Outlook emails from Excel; Limits to three emails only?
    By BPSJACK in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-29-2013, 06:53 AM
  6. Sending macro emails using excel: Send emails with their passwords.
    By loveisblind in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-12-2009, 03:16 PM
  7. Saved emails with attachments
    By ir26121973 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-04-2006, 02:10 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