Error sending email from Excel macro

TinaP

Well-known Member
Joined
Jan 26, 2005
Messages
528
I’m getting the error message Run-time error '-2147024770 (8007007e)' on the highlighted line of my code. This only happens on one computer. Other computers running the same macro work fine.
Code:
[FONT=Courier New]Sub Send_Request(RowNumber As Long)<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>[/FONT]
[FONT=Courier New]<o:p></o:p>[/FONT]
[FONT=Courier New]Dim OutApp As Object<o:p></o:p>[/FONT]
[FONT=Courier New]Dim OutMail As Object<o:p></o:p>[/FONT]
[FONT=Courier New]Dim Message As String<o:p></o:p>[/FONT]
[FONT=Courier New]Dim SecurityDept As String<o:p></o:p>[/FONT]
[FONT=Courier New]<o:p></o:p>[/FONT]
[FONT=Courier New]Application.DisplayAlerts = False<o:p></o:p>[/FONT]
[FONT=Courier New]<o:p></o:p>[/FONT]
[FONT=Courier New][COLOR=red]Set OutApp = CreateObject("Outlook.Application")[/COLOR][/FONT]
[FONT=Courier New]OutApp.Session.Logon<o:p></o:p>[/FONT]
[FONT=Courier New]Set OutMail = OutApp.CreateItem(0)<o:p></o:p>[/FONT]
[FONT=Courier New]Message = Compose_Message(RowNumber)<o:p></o:p>[/FONT]
[FONT=Courier New]With OutMail<o:p></o:p>[/FONT]
[FONT=Courier New]  .To = Cells(RowNumber, 25) & "@here.com"<o:p></o:p>[/FONT]
[FONT=Courier New]  If Cells(RowNumber, 28) >= 2 Then<o:p></o:p>[/FONT]
[FONT=Courier New]    .cc = SecurityDept<o:p></o:p>[/FONT]
[FONT=Courier New]  Else: .cc = ""<o:p></o:p>[/FONT]
[FONT=Courier New]  End If<o:p></o:p>[/FONT]
[FONT=Courier New]  .Subject = _<o:p></o:p>[/FONT]
[FONT=Courier New]    "Account ending in " & Right(Cells(RowNumber, 1), 4) & _<o:p></o:p>[/FONT]
[FONT=Courier New]    " opened/revised on " & Cells(RowNumber, 2)<o:p></o:p>[/FONT]
[FONT=Courier New]  .Body = Message<o:p></o:p>[/FONT]
[FONT=Courier New]  .Display<o:p></o:p>[/FONT]
[FONT=Courier New]'    .Send<o:p></o:p>[/FONT]
[FONT=Courier New]End With<o:p></o:p>[/FONT]
[FONT=Courier New]On Error GoTo 0<o:p></o:p>[/FONT]
[FONT=Courier New]<o:p></o:p>[/FONT]
[FONT=Courier New]Set OutMail = Nothing<o:p></o:p>[/FONT]
[FONT=Courier New]Set OutApp = Nothing<o:p></o:p>[/FONT]
[FONT=Courier New]Application.DisplayAlerts = True<o:p></o:p>[/FONT]
[FONT=Courier New]<o:p></o:p>[/FONT]
[FONT=Courier New]End Sub<o:p></o:p>[/FONT]

From what I can figure out, I need to re-register a dll or some other file, but I don't have any idea where to start. How do I find out what file needs to be re-registered on that computer?
 
Last edited:

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop

TinaP

Well-known Member
Joined
Jan 26, 2005
Messages
528
It took this long for me to get an opportunity to test the suggestion in the link, but it worked perfectly.

Since that link took forever to wade through, I'm reposting just the part of it that helped me:
If you get an error from a code statement like this:

Set ol = CreateObject("Outlook.Application")

the cause may be an anti-virus program on your computer that has a feature to block Outlook scripting. The solution is to turn off the script blocking feature.

If you're using Symantec Anti Virus, make a backup of the Windows registry, and then see if these changes solve the problem:

1. Go to the HKEY_CLASSES_ROOT\Outlook.Application\CLSID key and note the (Default) value. It will be a GUID, most likely {0006F03A-0000-0000-C000-000000000046}.

2. Now go to the key HKEY_CLASSES_ROOT\CLSID\{0006F03A-0000-0000-C000-000000000046}\InprocServer32 key, using the value from Step 1 if it's different from that shown above.

3. For the (Default) for that key, you should see this value:

C:\Program Files\Common Files\Symantec Shared\Script Blocking\ScrBlock.dll

Delete that text, so that the key's (Default) value becomes (value not set)


--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,163,424
Messages
5,831,556
Members
430,075
Latest member
Tuturino

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
Top