VBA to send email and letting the user select attachments

  • i created an userform to automate some emails i need to send everyday, basically i enter the account number and click a lookup button, this brings up the account and contact info from a database i have in excel. then i enter the doc number and amount and click a send button. a file selection window opens and asks me to select the attachment. after selecting an email is created using the info on the user form and the file is attached.


    this works ok when i am selecting one file but sometimes i need to select several attachments. i am having trouble with this part, the code i am using lets me select the files but it doesnt actually attach them.


    any advice on how i can set it up for multiple attachments? or is there another route i should be taking?


    i was thinking that of maybe having the macro write the file names somewhere on the excel file and then using .attachments.add and pointing at whereever excel wrote those files down. but im not sure how to go about that.


    anyone have any ideas?

  • Hello,


    You can test following proposal written by Norie


    Hope this will help

    If you feel like saying "Thank You" for the help received, do not hesitate to click the "Smiley" icon, below, in the bottom right corner :)

  • To attach multiple files using the code you provided, you will need to iterate over the array of file names returned by the GetOpenFilename function. Here's an example of how you can do this:


    I hope this helps! Let me know if you have any questions.



  • Hopefully OP will provide his feedback

    If you feel like saying "Thank You" for the help received, do not hesitate to click the "Smiley" icon, below, in the bottom right corner :)

Participate now!

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