Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Private Sub btnSendCalendar_Click()
Dim olApp As Object
Dim olMail As Object
Dim rs As DAO.Recordset
Dim strBody As String
Dim strDate As String
' Initialize Outlook application
Set olApp = CreateObject("Outlook.Application")
Set olMail = olApp.CreateItem(0) ' 0 = olMailItem
' Open the recordset for appointments
Set rs = CurrentDb.OpenRecordset("SELECT * FROM Appointments WHERE StartDate >= Date() AND EndDate < Date() + 30 ORDER BY StartDate")
' Build the email body
strBody = "<html><body><h2>Your Appointments for the Month</h2><table border='1'>"
strBody = strBody & "<tr><th>Subject</th><th>Start Date</th><th>End Date</th><th>Location</th></tr>"
' Loop through the appointments and add to the body
Do While Not rs.EOF
strBody = strBody & "<tr>"
strBody = strBody & "<td>" & rs!Subject & "</td>"
strBody = strBody & "<td>" & Format(rs!StartDate, "mm/dd/yyyy hh:nn AM/PM") & "</td>"
strBody = strBody & "<td>" & Format(rs!EndDate, "mm/dd/yyyy hh:nn AM/PM") & "</td>"
strBody = strBody & "<td>" & rs!Location & "</td>"
strBody = strBody & "</tr>"
rs.MoveNext
Loop
strBody = strBody & "</table></body></html>"
' Configure email properties
With olMail
.To = "recipient@example.com" ' Change to recipient's email
.Subject = "Monthly Appointments"
.HTMLBody = strBody
.Display ' Use .Send to send it directly
End With
' Clean up
rs.Close
Set rs = Nothing
Set olMail = Nothing
Set olApp = Nothing
End Sub