Excel VBA Send Email at Specific Date And Time

miew

New Member
Joined
Jan 15, 2023
Messages
3
Office Version
  1. 2019
Platform
  1. Windows
I need help with my VBA code. I wanna to make it when user click on button send email it will send email automatically according to the cells ("A1:A4") .

For instance, if today was 2 February 2023 it will send 3 emails for 6 February, 13 February and 20 February.

I had make the VBA code but the main problem is it just only send email for last cell ("A4").

For ("A2") AND ("A3") the email wont be send




DueDate
2/6/23 9:00
2/13/23 10:00
2/20/23 11:00

Sub Send_Deferred_Mail_From_Excel()
Dim OutlookApp As Object
Dim OutlookMail As Object

Dim xRg As Range
Set xRg = Range("A2:A4")
Set OutlookApp = CreateObject("Outlook.Application")
Set OutlookMail = OutlookApp.CreateItem(0)

'Send Email Using Excel VBA Macro Code
With OutlookMail
.To = "your email"
.CC = ""
.BCC = ""
.Subject = "Report"
.Body = "Hello"

'Send email on specific day & time
.DeferredDeliveryTime = Range("A2") + Range("A3") + Range("A4")
.Display 'or just put .Send to directly send the mail instead of display

End With
Set OutlookMail = Nothing
Set OutlookApp = Nothing
End Sub
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
I need help with my VBA code. I wanna to make it when user click on button send email it will send email automatically according to the cells ("A1:A4") .

For instance, if today was 2 February 2023 it will send 3 emails for 6 February, 13 February and 20 February.

I had make the VBA code but the main problem is it just only send email for last cell ("A4").

For ("A2") AND ("A3") the email wont be send




DueDate
2/6/23 9:00
2/13/23 10:00
2/20/23 11:00

Sub Send_Deferred_Mail_From_Excel()
Dim OutlookApp As Object
Dim OutlookMail As Object

Dim xRg As Range
Set xRg = Range("A2:A4")
Set OutlookApp = CreateObject("Outlook.Application")
Set OutlookMail = OutlookApp.CreateItem(0)

'Send Email Using Excel VBA Macro Code
With OutlookMail
.To = "your email"
.CC = ""
.BCC = ""
.Subject = "Report"
.Body = "Hello"

'Send email on specific day & time
.DeferredDeliveryTime = Range("A2") + Range("A3") + Range("A4")
.Display 'or just put .Send to directly send the mail instead of display

End With
Set OutlookMail = Nothing
Set OutlookApp = Nothing
End Sub
I want to send only to one person or one email with multiple reminder of email
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,177
Members
453,021
Latest member
Justyna P

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