Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sub AntMan()
- Dim OutLookApp As Object
- Dim OutLookMailItem As Object
- Dim lastRow As Long
- Dim MailDest As String
- Dim subj As String
- lastRow = ThisWorkbook.WorkSheets("Sheet6").Cells(Rows.Count, "A").End(xlUp).Row 'change worksheet
- For i = 2 To lastRow
- Set OutLookApp = CreateObject("Outlook.application")
- Set OutLookMailItem = OutLookApp.CreateItem(0)
- Set Attach = OutLookMailItem.Attachments
- With OutLookMailItem
- .To = Cells(i, 1).Value
- .SUBJECT = "Put your subject here"
- .Body = "Put your body here"
- Attach.Add "C:yourfilepathhere" & Cells(i, 2).Value & ".xlsx"
- .Display 'for debugging
- .Send
- End With
- Next
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement