Help needed, run-time error -2147417851 (80010105)

Kestis

New Member
Joined
Jan 25, 2015
Messages
22
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.

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
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
As far as I know, it has something to do with OS, everything works fone under Vista (probalby Windows 7) but it does not work under Windows 8.1.
Maybe someone knows what could be the problem?
 
Upvote 0

Forum statistics

Threads
1,215,488
Messages
6,125,092
Members
449,206
Latest member
ralemanygarcia

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top