Maccro to send email and attach file related to the recipient

arthur8

New Member
Joined
Jan 21, 2016
Messages
5
Hi y'all , I have a tricky issue here ;

I'm working on a code that would send an email to a list of clients with attachment that are related to these people.
The Files (Attachments) are saved via a maccros that uses the name of the client in Sheet 2 Col A to integrate their names in the file's name.ie : ClientName.xlsm (Sheet2 is a list of name generated by another maccros, therefor I cant modify it ) :


Dim pt As Pivottable
Dim Field As PivotField
Dim ClientName As String
Dim wb As Workbook


Set pt = Worksheets("Sheet4").PivotTables("PivotTable1")
Set Field = pt.PivotFields("SUPPLIER")

(((((This first part copies the name of the client in a pivot table filter and generate a report , the report is what I want to send )))))
Dim r As Integer

r = 1

Do Until Worksheets("Sheet2").Cells(r, 1).Value = ""

ClientName = Worksheets("Sheet2").Cells(r, 1).Value

With pt
Field.ClearAllFilters
Field.CurrentPage = NewSup
pt.RefreshTable
End With


Set wb = Workbooks.Add
ThisWorkbook.Sheets("Sheet4").Copy before:=wb.Sheets(1)
Columns("E:F").Select
Selection.Locked = False
Selection.FormulaHidden = False
ActiveWindow.SmallScroll Down:=-9
Range("A1").Select
ActiveSheet.Protect "

wb.SaveAs "C:\Users\FolderXXX & ClientName & ".xls

wb.Close False

r = r + 1

Loop

so this code works .. now I want to send those attachement to the clients ... The clients contact details are in sheet 3 of the same workbook , Col A = ClientName Col D = clientEmailAdress. Don't know if thats clear enough .. :eek:
Thanks for your help !! :)
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
Hah yesm I've already checked this thread , but I think it's missing somethg , thanks for your time and help, appreciated: )
 
Upvote 0

Forum statistics

Threads
1,216,583
Messages
6,131,557
Members
449,655
Latest member
Anil K Sonawane

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top