I have created an auto mailer where my goal is to add X number of days to the reference date value and will send the email based on the output value in the Pivot Table using Macro but i am kind of got stuck from the code i have created below. For example, D16 contains 04/02/2021, macro should be able to read and add 15 days if X = 15 then it will send an email on 19/02/2021. Any advice or help is appreciated.
Sub email()
Dim r As Range
Dim cell As Range
Set r = Range("D16")
For Each cell In r
If cell.Value <> "" Then
Dim Email_Subject, Email_Send_From, Email_Send_To, _
Email_Cc, Email_Bcc, Email_Body As String
Dim Mail_Object, Mail_Single As Variant
Email_Subject = "subject"
Email_Send_From = "[email protected]"
Email_Send_To = "[email protected]"
Email_Body = "sdsdsdsdsdy"
'On Error GoTo debugs
Set Mail_Object = CreateObject("Outlook.Application")
Set Mail_Single = Mail_Object.CreateItem(0)
With Mail_Single
.Subject = Email_Subject
.To = Email_Send_To
.cc = Email_Cc
.BCC = Email_Bcc
.Body = Email_Body
'.display
.send
End With
End If
Next
Exit Sub
'debugs:
'If Err.Description <> "" Then MsgBox Err.Description
End Sub
question from:
https://stackoverflow.com/questions/66048226/add-x-number-of-days-to-a-cell-date-value-from-a-pivot-table 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…