StartDownloadsServiceSamplesWorkshopsContact DeutschEnglish
 
Samples
General
Outlook®
 
Awarded by
Microsoft since 2005:
mvp logo
VBOffice Info
Visitors1826702
Impressions6852839
Links
Imprint
Privacy Policy
Contact
Calendar: Confirm appointment by e-mail
Author: Michael BauerHomepage
Date: 24.08.2010Accessed: 11495
  
Description

This example demonstrates

- for Outlook 2007 or higher how to create your own context menu button, which is displayed when you right-click an appointment item in the folder view

- and how to access a contact item that is linked to this appointment.

The example creates an email with the subject of the appointment and confirms the date. If you have entered a contact at the bottom of the appointment form, the email is automatically addressed to this contact.

Please see the source code, there're two places commented with 'Edit' where you can adjust the caption of the button as well as the subject and the body of the email.

(Copy the code to ThisOutlookSession)

Private WithEvents ConfirmAppointment As Office.CommandBarButton

Private Sub Application_ItemContextMenuDisplay(ByVal CommandBar As Office.CommandBar, _
  ByVal Selection As Selection)
  Dim obj As Object
  Dim Item As Outlook.AppointmentItem
  Dim Btn As Office.CommandBarButton
  Dim Caption$

    ' Edit
  Caption = "Confirm Appointment"

  If Selection.Count = 1 Then
    Set obj = Selection(1)
    If TypeOf obj Is Outlook.AppointmentItem Then
      Set Item = obj
      Set Btn = CommandBar.Controls.Add(msoControlButton, , , , True)
      Btn.Style = msoButtonCaption
      Btn.Caption = Caption
      Btn.Parameter = Item.EntryID
      Set ConfirmAppointment = Btn
    End If
  End If
End Sub

Private Sub ConfirmAppointment_Click(ByVal Ctrl As Office.CommandBarButton, _
  CancelDefault As Boolean)
  Dim Appt As Outlook.AppointmentItem
  Dim Mail As Outlook.MailItem
  Dim Link As Outlook.Link
  Dim Contact As Outlook.ContactItem
  Dim Message$, StartTime$, Recipient$, Subject$
  Dim EntryID$

  EntryID = Ctrl.Parameter
  If Len(EntryID) Then
    Set Appt = Application.Session.GetItemFromID(EntryID)
  End If

  If Not Appt Is Nothing Then
    Set Mail = Application.CreateItem(olMailItem)

    If Appt.Links.Count Then
      Set Link = Appt.Links(1)
      If Not Link.Item Is Nothing Then
        Set Contact = Link.Item
        If Not Contact Is Nothing Then
          Recipient = Contact.Email1Address
        End If
      End If
    End If

    ' Edit
    Subject = "Confirmation: " & Appt.Subject
    Message = "Herewith I confirm the following appointment: "

    StartTime = Format(Appt.Start, "dddd, dd. mmm yyyy hh:nn", vbUseSystemDayOfWeek, vbFirstFourDays)
    Message = Message & vbCrLf & StartTime

    Mail.To = Recipient
    Mail.Subject = Subject
    Mail.Display
    Mail.Body = Message & Mail.Body
  End If

  Set ConfirmAppointment = Nothing
End Sub
 
 

ReplyAll alerts you before unintentionally replying all, or if you are a confidential BCC recipient of the ... [more]

 

Access the master category list in the blink of an eye, share your categories in a network, get a reminder service, and ... [more]

 

SAM automatically sets the sender, signature, and folder for sent items, for instance based on the recipient ... [more]

 

OLKeeper reliably prevents users from closing their Outlook window and thus possibly missing reminders or ... [more]