Hi,
I am trying to set up a spreadsheet to monitor our small vehicle fleet.
I have a spreadsheet which we record when the Tax, MOT, Service and Fuel Cards are due, I have conditional formatting set up to change the cells format depending on when they are due.
I would now like to update / automate this a little.
I want to set up way of an email automatically being sent out listing the vehicles and what is due when, the email would go out to an email address or list of email addresses stored cells in the excel sheet -- even better if this could run once a week without having to open the file using OneDrive
I have used the following from the web which sort of works but limited to running the macro and returns to much info.
The email would only need to be sent and include vehicles that are due within 30 days.
Hope this makes sense.
Sub SendEmailReminder()
Dim OutlookApp As Object
Dim OutlookMail As Object
Dim cell As Range
Set OutlookApp = CreateObject("Outlook.Application")
For Each cell In Range("B2:B10")
If cell.Value <= Date Then
Set OutlookMail = OutlookApp.CreateItem(0)
With OutlookMail
.To = "your-email@example.com"
.Subject = "Task Reminder"
.Body = "Task " & cell.Offset(0, -1).Value & " is due!"
.Send
End With
End If
Next cell
End Sub
I am trying to set up a spreadsheet to monitor our small vehicle fleet.
I have a spreadsheet which we record when the Tax, MOT, Service and Fuel Cards are due, I have conditional formatting set up to change the cells format depending on when they are due.
I would now like to update / automate this a little.
I want to set up way of an email automatically being sent out listing the vehicles and what is due when, the email would go out to an email address or list of email addresses stored cells in the excel sheet -- even better if this could run once a week without having to open the file using OneDrive
I have used the following from the web which sort of works but limited to running the macro and returns to much info.
The email would only need to be sent and include vehicles that are due within 30 days.
Hope this makes sense.
Sub SendEmailReminder()
Dim OutlookApp As Object
Dim OutlookMail As Object
Dim cell As Range
Set OutlookApp = CreateObject("Outlook.Application")
For Each cell In Range("B2:B10")
If cell.Value <= Date Then
Set OutlookMail = OutlookApp.CreateItem(0)
With OutlookMail
.To = "your-email@example.com"
.Subject = "Task Reminder"
.Body = "Task " & cell.Offset(0, -1).Value & " is due!"
.Send
End With
End If
Next cell
End Sub