Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

mail merge with attachments 2

Status
Not open for further replies.

gussy81

Programmer
Jun 12, 2023
11
IE
Hi,

I am trying to run a VB script that generates email with doc attached. I have the script below but inly generates one email - I have 5 rows on my source excel doc. the script below does what i want but only creates one email with the attachment.

Any help here would be great.

[pre]
Sub Single_attachment()
Dim appOutlook As Object
Dim Email As Object
Dim Source, mailto As String
Set appOutlook = CreateObject("Outlook.Application")
Set Email = appOutlook.CreateItem(olMailItem)
mailto = mailto & Cells(2, 2) & ";"
Source = "C:\Users\fk\Desktop\test invoices email\" & Cells(2, 3)
Email.Attachments.Add Source
ThisWorkbook.Save
Source = ThisWorkbook.FullName
Email.Attachments.Add Source
Email.To = mailto
Email.Subject = "Important Sheets"
Email.Body = "Greetings Everyone," & vbNewLine & "Please go through the Sheets." & vbNewLine & "Regards."
Email.Display
End Sub


[/pre]
 
Greetings Everyone" - sounds weird when you send an e-mail to just one person and you have this person's name in column A. Use it.
"Please go through the Sheets." - pdf's dont have 'Sheets', do they [ponder]

combo's guess that "you need five emails to five recipients, with one attachment each" was just a 'shot in the dark' or an 'educated guess' (I would assume :) ) because you had never specified this in your posts. If you would state clearly your requirements, you would be done a long time ago.


---- Andy

"Hmm...they have the internet on computers now"--Homer Simpson
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top