Excel VBA Course
Excel VBA Course - From Beginner to Expert

200+ Video Lessons
50+ Hours of Video
200+ Excel Guides

Become a master of VBA and Macros in Excel and learn how to automate all of your tasks in Excel with this online course. (No VBA experience required.)

View Course

Email remainders via excel with vba

0

I just got the course for email remainders but I wold like you to help on how to uautomatically send the email if and especific date is reach or some days before a date. 

Answer
Discuss

Discussion

Hi Rod and welcome to the Forum 

I don't have that course (and answers on that are generally to be obtained directly from Don using the Contact form and the Premium course option).

It's certainly possible to use VBA to send an email on a given date (or prior to same) but do you need one email or have a list of several emails (each with different dates etc.)? Please edit your original question to clarify. Better still (if you need several), please attach a representative Excel file using the Add Files button when editting your question. 
John_Ru (rep: 6377) Aug 12, '24 at 5:24 pm
Add to Discussion

Answers

0

Hi Rod and welcome,

You could use somrthing like:

Sub SendEmail()

' Email variables.
Dim outlookApp As Object
Dim emailItem As Object
Dim emailSubject As String
Dim emailBody As String

' Get a reference to the Outlook Application Object.
Set outlookApp = CreateObject("Outlook.Application")

' Create the Email Object Item
Set emailItem = outlookApp.CreateItem(0)

' Setup values for the email.
emailSubject = "This is the Subject Line for the email."
emailBody = "This is the message for the email."

' Build and Send the Email
With emailItem
    .To = "someone1@somewhere.com; someone2@somewhere.com"
    .CC = "anybody1@anywhere.com; anybody2@anywhere.com"
    .BCC = "everyone1@everywhere.com; everyone2@everywhere.com"
    .Subject = emailSubject
    .Body = emailBody
    .Attachments.Add ThisWorkbook.FullName
    ' A1 must be formatted as date - yyyy-mm-dd
    ' B1 must be formatted as time
    .DeferredDeliveryTime = Range("A1").Value & " " & Range("B1").Value
    .Display
    '.Send
End With

End Sub

Change the To, CC,  and BCC lines as needed. The line "DeferredDeliveryTime" can also be hard coded. If you want multiple delayed emails simply have a line for each instance.

Hope this helps.

Cheers   :-)

Discuss

Discussion

Hi Rod,
Did my answer solve things for you? If so, please mark my answer as Selected. If not, please comment on how it missed the mark so improvements can be made.
WillieD24 (rep: 587) Aug 17, '24 at 10:40 am
Add to Discussion


Answer the Question

You must create an account to use the forum. Create an Account or Login