How to Quickly Send Your Today’s Appointments to Someone via Outlook VBA

At times, you may need to extract and send your today’s appointments to someone. Without any doubts, searching and attaching such appointments one by one is quite cumbersome. So this article will teach you how to quickly get it via VBA.

By default, Outlook permits you to email a calendar and specify the date range of the calendar. But by this way, the entire Today’s calendar will be sent, shown as the following screenshot:

E-mail Calendar

If you simply desire to send today’s appointment items, like the image below, then the above “E-mail Calendar” method may be not suitable for your case.Send Today's Appointments

Fortunately, you can make use of Outlook VBA to quickly realize it. The followings are the elaborate steps and corresponding VBA codes.

Quickly Send Your Today’s Appointments to Someone

  1. In the first place, you should launch your Outlook.
  2. Then you need to switch to “Developer” tab. If not see such a tab, you ought to customize ribbon to enable it firstly.
  3. Next under “Developer” tab, click on the “Visual Basic” button.
  4. Subsequently, the VBA editor window will display. Now you have to open a module which are not in use or straightly insert a new one by hitting “Insert” > “Module” in the toolbar.
  5. After that, you need to copy and paste the following VBA codes into it.
Sub MailTodayAppointments()
    Dim objAppointments As Outlook.Items
    Dim objTodayAppointments As Outlook.Items
    Dim strFilter As String
    Dim objAppointment As Object
    Dim strSubject As String
    Dim strStart As String
    Dim strEnd As String
    Dim strLocation As String
    Dim strTodayAppointmentList As String
    Dim objNewMail As Outlook.MailItem

    Set objAppointments = Application.Session.GetDefaultFolder(olFolderCalendar).Items
 
    objAppointments.Sort "[Start]", True
    objAppointments.IncludeRecurrences = True
 
    'Find your today's appointments
    strFilter = Format(Now, "ddddd")
    strFilter = "[Start] <= " & Chr(34) & strFilter & " 11:59 PM" & Chr(34) & " AND [End] > " & Chr(34) & strFilter & " 00:00 AM" & Chr(34)
    Set objTodayAppointments = objAppointments.Restrict(strFilter)
 
    'Create a new email
    Set objNewMail = Application.CreateItem(olMailItem)
 
    'Extract the primary details of the today's appointments
    For Each objAppointment In objTodayAppointments
        strSubject = objAppointment.Subject
        strStart = Format(objAppointment.Start, "mm/dd hh:mm AMPM")
        strEnd = Format(objAppointment.End, "mm/dd hh:mm AMPM")
        strLocation = objAppointment.Location
        strTodayAppointmentList = strSubject & vbTab & strStart & " ~ " & strEnd & vbTab & vbTab & strLocation & vbCrLf & "--------------------------------------------------------------------------------------" & vbCrLf & strTodayAppointmentList
 
        'Specify the email details
        With objNewMail
             .Subject = "My Today's Appointments"
             .attachments.Add objAppointment
             .Body = "--------------------------------------------------------------------------------------" & vbCrLf & strTodayAppointmentList
             .Display
        End With
    Next
End Sub

VBA Codes - Send Your Today's Appointments to Someone

  1. Later you will be required to check your Outlook security settings, ensuring that macros are enabled.
  2. After that, you can click the “Run” icon in the toolbar of the VBA editor.Run the New VBA Project
  3. Finally a new email will be created and it will look like the second screenshot in this post.

Pay Attention to Outlook Data Protection

Some users mistakenly feel that they haven’t suffered Outlook corruption since they used Outlook, so they won’t encounter it in the future. This thought is totally wrong. Don’t bypass the Outlook data protection. Outlook can crash and your PST data can get lost in a flash and without any omens. Therefore, you have to make various and sufficient precautions, such as regular backups and a proven repair tool, like DataNumen Outlook Repair and so on.

Author Introduction:

Shirley Zhang is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including mdf repair and outlook repair software products. For more information visit www.datanumen.com

Comments are closed.