0 votes
in VBA by Beginner (36 points)
Hi guys

I have a task that requires me to email and attach unique documents to different people. The files I want to attach are all in a specific folder (so that solves the filepath)

I had a poke around and saw this (https://wellsr.com/vba/2018/excel/excel-vba-send-email-with-attachment/) but that solution has everyone getting the same thing. What we require is Person A getting attachment A and person B getting attachment B.

I am very sure there is a solution to this that does not involve making a draft in Outlook, copying it multiple times and then copy paste the email address and dragging the attachments (yes, I have been doing that this whole time!!!)
by Expert (892 points)
May be creating a helper column and in that column you insert the full path for each attachment .. and of course in the same row there is information about the email you will send the email.
by Beginner (36 points)

Hi there; thanks for the idea for the helper column. I tried it and I think I'm nearly there.

With the following code:

myMail.Subject = "Files for Everyone"
Would it be possible to change it to a fixed cell ie G2 (fixed for every recipient)?
I tried to use
myMail.Subject = Range(G2).Value

but that seems to fail. Any ideas?

Thanks again!


by Expert (892 points)
Put the reference to G2 between quotation marks Range("G2").Value
by Beginner (36 points)
Brilliant!!!! Got the To, CC, BCC and subject thing working. Now to get the part about attachements working.

Thanks again!
by Beginner (36 points)
edited by
Thanks to all for helping! I think I saved my mouse and keyboard from too much clicking!
by Expert (892 points)
You're welcome. Glad I can offer little help.

1 Answer

0 votes
by Beginner (25 points)
thinking you have a list what email you're going to send for each. Then make a loop for all files should be attach, put it into other loop for each who will receive these. I mean the loop for file that attached must be next before the loop for person next. because you need send one by one. Hope can help you in this case.

Welcome to wellsr Q&A
wellsr Q&A is the VBA and Python programming community that rewards you for learning how to code.

Getting Started
VBA Cheat Sheets (On Sale Now)

Earn free prizes for asking VBA and Python questions and for answering questions asked by others in our community.

Looking for something else? Hire our professional VBA Help, instead.

What makes us different?
Our points system rewards you with a chance for free gifts based on the quality of your questions and answers. All you have to do is post and you could get rewarded, like these members:

ParserMonster $25 Amazon Gift Card
Hightree $10 Amazon Gift Card
Thales1 $10 Amazon Gift Card
runfunke $10 Amazon Gift Card
coolag $10 Amazon Gift Card
Siew Hun $10 Amazon Gift Card

So, why don't you join us? It really is an encouraging way to motivate members in our VBA and Python community.


For more programming tips visit the VBA Tutorials Blog and the Python Tutorials Blog.