Hi all,
I am trying to set up an VBA to send email at specific date and time. But I cannot properly set
line. It returns Run-time error 440, The object does not support this method. Any ideas how to fix it?
Cell with date is custom formatted as DD-MMM-YYYY, and cell with hour is formatted as Time
I am trying to set up an VBA to send email at specific date and time. But I cannot properly set
VBA Code:
.DeferredDeliveryTime
Cell with date is custom formatted as DD-MMM-YYYY, and cell with hour is formatted as Time
VBA Code:
Sub RectangleRoundedCorners4_Click()
Dim OutlookApplication As Object
Dim OutlookMail As Object
Dim ws As Worksheet
Dim Ads As String
Dim Subj As String
Dim Body As String
Dim DelDate As Date
Dim DelHour As Integer
Dim DelMin As Integer
Set OutlookApplication = CreateObject("Outlook.Application")
Set OutlookMail = OutlookApplication.CreateItem(0)
Set ws = ActiveSheet
Ads = ws.Cells(4, 2).Value
Subj = ws.Cells(7, 2).Value
Body = ws.Cells(4, 9).Value
DelDate = ws.Cells(10, 6).Value
DelHour = Hour(ws.Cells(12, 6).Value)
DelMin = Minute(ws.Cells(12, 6).Value)
With OutlookMail
.To = Ads
.CC = ""
.BCC = ""
.Subject = "REMINDER: " & Subj
.Body = Body
.DeferredDeliveryTime = DelDate & DelHour
End With
Set OutlookMail = Nothing
Set OutlookApplication = Nothing
End Sub
Book1 | |||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | |||
1 | |||||||||||||||||||
2 | |||||||||||||||||||
3 | Addres: | Text: | |||||||||||||||||
4 | email@email.com | Why are you not working?! | |||||||||||||||||
5 | |||||||||||||||||||
6 | Subject (will automatically begin with REMINDER) | ||||||||||||||||||
7 | Test | ||||||||||||||||||
8 | |||||||||||||||||||
9 | Date: | ||||||||||||||||||
10 | 15-Nov-2022 | ||||||||||||||||||
11 | Time: | ||||||||||||||||||
12 | 10:00 | ||||||||||||||||||
13 | |||||||||||||||||||
14 | |||||||||||||||||||
15 | |||||||||||||||||||
16 | |||||||||||||||||||
17 | |||||||||||||||||||
18 | |||||||||||||||||||
19 | |||||||||||||||||||
20 | |||||||||||||||||||
21 | |||||||||||||||||||
22 | |||||||||||||||||||
23 | |||||||||||||||||||
Sheet1 |