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
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
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