What is wrong with my code? I received "Run-time error 91: Object variable or With block variable not set". My source_file is able to get the correct file location as string but the my_attachments just shows nothing in the locals. The source_file shows 2 locations:
C:\Users\User\Desktop\test.txt; C:\Users\User\Desktop\test2.txt
Locals.JPG
Sub SendEmail(what_address As String, CC_address As String, subject_line As String, mail_body As String, my_attachments As Object)
Dim olapp As Outlook.Application
Set olapp = CreateObject("Outlook.Application")
Dim olMail As Outlook.MailItem
Set olMail = olapp.CreateItem(olMailItem)
olMail.Attachments = my_attachments
End Sub
Sub SendMassEmail()
Dim source_file As String
Dim my_attachments As Object
source_file = ws.Range("G4")
my_attachments.Add source_file
Call SendEmail(ws.Range("A" & row_number), ws.Range("B" & row_number), mail_subject, mail_body_message, my_attachments)
End Sub
Bookmarks