DeferredDeliveryTime help

PugradorTX

New Member
Joined
Sep 15, 2023
Messages
4
Office Version
  1. 365
Platform
  1. Windows
I'm a newbie at VBA and don't know what i'm doing wrong. I'm simply trying to delay delivery on bulk emails by adding the following line to an existing code someone else had helped me with.

VBA Code:
msg.DeferredDeliveryTime = "12/14/2023" & "11:20:00 AM"

My full VBA code is as follows, but I'm obviously missing something because when I try to run it the spreadsheet keeps giving me a "Run-time error '440': The object does not support this method."

VBA Code:
Sub Send_Bulk_Mails()
Dim sh As Worksheet
Set sh = ThisWorkbook.Sheets("Monthly Budget")
Dim i As Integer

Dim OA As Object
Dim msg As Object

Set OA = CreateObject("outlook.application")

Dim last_row As Integer
last_row = Application.CountA(sh.Range("A:A"))

For i = 2 To last_row
Set msg = OA.createitem(0)
msg.to = sh.Range("A" & i).Value
msg.cc = sh.Range("B" & i).Value
msg.Subject = sh.Range("C" & i).Value
msg.body = sh.Range("D" & i).Value
msg.DeferredDeliveryTime = "12/14/2023" & "11:20:00 AM"

If sh.Range("E" & i).Value <> "" Then
msg.attachments.Add sh.Range("E" & i).Value
End If

msg.display

sh.Range("F" & i).Value = "Sent"

Next i

MsgBox "All emails have been sent"



End Sub
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
It may be how you're creating the object. I can't seem to find what "CreateItem(0)" references, but the examples I keep finding use the following syntax referencing the "olMailItem":

VBA Code:
'Creates a new email item and modifies its properties
Dim objMail As Outlook.MailItem

Set objMail = Application.CreateItem(olMailItem)

or

VBA Code:
Set olApp = New Outlook.Application
Set olMail = olApp.CreateItem(olMailItem)
 
Upvote 0

Forum statistics

Threads
1,215,111
Messages
6,123,152
Members
449,098
Latest member
Doanvanhieu

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