VBA - Outlook object not found

nuckfuts

New Member
Joined
Mar 10, 2020
Messages
47
Office Version
  1. 365
Platform
  1. Windows
Hi all - I have a VBA code that automatically sends messages. It's been working for >1 year, however now I am getting below error.

Run-time error '-2147221233 (8004010f)':

The attempted operation failed. An object could not be found.

Code (snags on last line):
VBA Code:
Sub SendEmail (i As Long)
Dim olApp As Outlook.Application
Dim olNs As Namespace
Dim FlDr as MAPIFolder
Dim subfldr As Outlook.Folder
Dim olMail As Outlook.MailItem
Dim olReply As Outlook.MailItem
Dim olItems As Outlook.Items
Dim k As Integer
Dim sSubject As String
Dim objDoc As Object
Dim objBkm As Object
Dim OutMail As Object
Dim OutApp As Object
Dim Signature As String
Dim MsgHistory As String
Dim newBody As String
Dim startBody As String
Dim sp, ep As String
Dim T5 As String
Dim pymt As String
Dim rcpt As String
Dim ctp As String
Dim IsOutlookCreated As Boolean

sp = "<p style='font-family:calibri;fontsize:11'>"
ep = "</p>"

Application.ScreenUpdating = False
    Set olApp = New Outlook.Application
    Set olNs = olApp.GetNamespace("MAPI")
    Set FlDr = olNs.GetDefaultFOlder(olFolderInbox)
    Set subfldr = FlDr.Folders("Subfolder_Name")

Apologies for the redundancies and (probably) terrible code structure.
I've checked everything, subfolder name matches exactly to code. Subfolder lies directly under Inbox as it always has. Any ideas?

Thx
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Silly question, possibly, but do you have the appropriate References enabled as well?
 
Upvote 0
In the VBA editor -> Tools -> References, do you have Microsoft Outlook 16.0 Object Library ticked?

Disclaimer: I'm still relatively new to VBA myself, but one of the problems I had was because I did not have a certain reference enabled that was necessary. It seems logical that since you're calling Outlook, you'd likely need the object library, too.
 
Upvote 0
In the VBA editor -> Tools -> References, do you have Microsoft Outlook 16.0 Object Library ticked?

Disclaimer: I'm still relatively new to VBA myself, but one of the problems I had was because I did not have a certain reference enabled that was necessary. It seems logical that since you're calling Outlook, you'd likely need the object library, too.
Ah, sorry - been awhile since I created this. Yes - it's ticked, just double checked.
 
Upvote 0

Forum statistics

Threads
1,214,409
Messages
6,119,339
Members
448,888
Latest member
Arle8907

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