Jyggalag
Active Member
- Joined
- Mar 8, 2021
- Messages
- 445
- Office Version
- 365
- 2019
- Platform
- Windows
Hi all (please scroll to the bottom for the question),
I am currently trying to use the following code to send out word documents through a vba macro (source: Using Excel VBA to Send Emails with Attachments - wellsr.com):
In code format:
I have tried to change this a bit so it fits my own code, where I already dimmed a lot of it prior to finding this code. I have therefore written:
My issue now is that whenever I try to run the code, it says the following:
Does anybody know how I can fix this issue?
Would be very much appreciated!!
Thank you all
Kind regards,
Jyggalag
I am currently trying to use the following code to send out word documents through a vba macro (source: Using Excel VBA to Send Emails with Attachments - wellsr.com):
In code format:
VBA Code:
Sub AttachMultipleFilesToEmail()
Dim outlookApp As Outlook.Application
Dim myMail As Outlook.MailItem
Set outlookApp = New Outlook.Application
Set myMail = outlookApp.CreateItem(olMailItem)
For i = 2 To 5
source_file = "C:\Work Files\" & Cells(i, 3)
myMail.Attachments.Add source_file
Next i
End Sub
I have tried to change this a bit so it fits my own code, where I already dimmed a lot of it prior to finding this code. I have therefore written:
VBA Code:
Dim EmailApp As Outlook.Application
Dim Source As String
Set EmailApp = New Outlook.Application
Dim EmailItem As Outlook.MailItem
Set EmailItem = EmailApp.CreateItem(olMailItem)
My issue now is that whenever I try to run the code, it says the following:
Does anybody know how I can fix this issue?
Would be very much appreciated!!
Thank you all
Kind regards,
Jyggalag
Last edited by a moderator: