PugradorTX
New Member
- Joined
- Sep 15, 2023
- Messages
- 4
- Office Version
- 365
- Platform
- 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.
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:
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