Excel Help Needed

JenKay0118

New Member
Joined
Feb 22, 2023
Messages
1
Office Version
  1. 2016
Platform
  1. Windows
Hello,

I am looking for a way (possibly through a VBA Code) to have an email sent from Excel.

The email address is not in the Excel document so it would need to be embedded in the code.
I would like the email to be sent at 6 AM the day before the expiration date that is in a specific cell in the Excel document.
I would like the Subject line to contain a document number that is in a specific cell in the Excel document.
I would like the Body of the email to read "Expiration Date is tomorrow" or something like that.

I have never used VBA codes before so step-by-step instructions would be appreciated.

Thank you in advance
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
You should be able to accomplish this task with a VBA code. Here's a sample code that you can use as a starting point:

VBA Code:
Sub Send_Excel_Email()
    Dim OutApp As Object
    Dim OutMail As Object
    Dim ExpDate As Date
    Dim DocNumber As String

    'Get the expiration date and document number
    ExpDate = Range("A1").Value 'Change this depending on where the date is stored
    DocNumber = Range("B1").Value 'Change this depending on where the document number is stored

    On Error GoTo Errorhandler
    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(0)

    With OutMail
        .To = "example@example.com"
        .CC = ""
        .BCC = ""
        .Subject = "Expiration Date for " & DocNumber & " is tomorrow"
        .Body = "Expiration Date is tomorrow"
        .Send
    End With

Errorhandler:
    Set OutMail = Nothing
    Set OutApp = Nothing
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,818
Messages
6,121,725
Members
449,049
Latest member
MiguekHeka

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