Advertisement
Guest User

Untitled

a guest
Feb 13th, 2016
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. Sub AntMan()
  2.  
  3. Dim OutLookApp As Object
  4. Dim OutLookMailItem As Object
  5. Dim lastRow As Long
  6. Dim MailDest As String
  7. Dim subj As String
  8.  
  9. lastRow = ThisWorkbook.WorkSheets("Sheet6").Cells(Rows.Count, "A").End(xlUp).Row 'change worksheet
  10.  
  11. For i = 2 To lastRow
  12.  
  13. Set OutLookApp = CreateObject("Outlook.application")
  14. Set OutLookMailItem = OutLookApp.CreateItem(0)
  15. Set Attach = OutLookMailItem.Attachments
  16.  
  17. With OutLookMailItem
  18. .To = Cells(i, 1).Value
  19. .SUBJECT = "Put your subject here"
  20. .Body = "Put your body here"
  21. Attach.Add "C:yourfilepathhere" & Cells(i, 2).Value & ".xlsx"
  22. .Display 'for debugging
  23. .Send
  24. End With
  25.  
  26. Next
  27.  
  28. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement