Looping code to add multiple attachments to an email.

  • Its been a couple of years since I've done anything with VBA so I'm very rusty. I'm trying to improve some of our existing systems whilst i have some time to do so.

    I have code that will produce an invoice from the database, save it on the server and then attach it to an email.

    What I want to do now is for the code (where it adds attachments to email) to loop through and do this for all records in the record set (whilst also updating the date it happened so they are not on the future record set).

    To be clear, all records in the recordset should be put into one email.

    I will show the code that works for individual invoices/records. Ill also show my attempt at making it loop. The issue with the looping is; It will create multiple email windows and not add any attachments. Any ideas or advice would be appreciated.

    Working code for individual invoice:

    My attempt at making it loop:

    I have tried different variations and I'm pretty stuck for ideas at the moment.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!