Hello, I am trying to excecute this script, but it gives me the following error:
Run-time error -2147417851 (80010105)
Method 'To' of object'_MailItem' failed
What could be the problem? Earlier this script was working without any problems.
I am using Office 2010.
Run-time error -2147417851 (80010105)
Method 'To' of object'_MailItem' failed
What could be the problem? Earlier this script was working without any problems.
I am using Office 2010.
Code:
Sub SendMultipleEmails()
Dim Attach As Object
Dim myolApp As Object
Dim Mail As Object
Set myolApp = CreateObject("Outlook.Application")
For i = 2 To 101
Set Mail = myolApp.CreateItem(olMailItem)
Set Attach = Mail.Attachments
Mail.To = Cells(i, 1)
Mail.CC = Cells(i, 2)
Mail.BCC = Cells(i, 3)
Mail.Subject = Cells(i, 4)
Mail.Body = Cells(i, 5)
If Cells(i, 6) <> "" Then
Attach.Add "" & Cells(i, 6) & ""
End If
Mail.send
Next