Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Use Automation to Add Meeting Request to Microsoft Outlook

How To

How to Use Automation to Add Meeting Request to Microsoft Outlook

by  hengsin  Posted    (Edited  )
BEFORE READ THIS FAQ, PLEASE GO TO http://support.microsoft.com/default.aspx?scid=kb;EN-US;209963 BECAUSE I'M ONLY ADD IN FEW LINES OF CODE. I AM WORKING ON MICROSOFT OFFICE 2000. I HAVEN'T TESTED IN OFFICE 97 OR OFFICE XP.

Private Sub cmdAddAppt_Click()
On Error GoTo Add_Err

'Save record first to be sure required fields are filled.
DoCmd.RunCommand acCmdSaveRecord

'Exit the procedure if appointment has been added to Outlook.
If Me!AddedToOutlook = True Then
MsgBox "This appointment is already added to Microsoft Outlook"
Exit Sub
'Add a new appointment.
Else
Dim objOutlook As Outlook.Application

Dim objAppt As Outlook.AppointmentItem

Set objOutlook = CreateObject("Outlook.Application")
Set objAppt = objOutlook.CreateItem(olAppointmentItem)

'CHANGE APPOINMENT ITEM TO A MEETING
objAppt.MeetingStatus = Outlook.OlMeetingStatus.olMeeting


'ADD ATTENDEE
Dim oRecipt As Outlook.Recipient
Dim strRecipients As String

strRecipients = "Someone Name As in Global Address List"

With objAppt
'Add the recipient to the Meeting Request
Set oRecipt = .Recipients.Add(strRecipients)
oRecipt.Type = olTo

.Start = Me!ApptDate & " " & Me!ApptTime
.Duration = Me!ApptLength
.Subject = Me!Appt

If Not IsNull(Me!ApptNotes) Then .Body = Me!ApptNotes
If Not IsNull(Me!ApptLocation) Then .Location = Me!ApptLocation
If Me!ApptReminder Then
.ReminderMinutesBeforeStart = Me!ReminderMinutes
.ReminderSet = True
End If


.Save
'.Close

End With
'Release the AppointmentItem object variable.
Set objAppt = Nothing

End If

'Release the Outlook object variable.
Set objOutlook = Nothing

'Set the AddedToOutlook flag, save the record, display a message.
Me!AddedToOutlook = True
DoCmd.RunCommand acCmdSaveRecord
MsgBox "Appointment Added!"

Exit Sub

Add_Err:
MsgBox "Error " & Err.Number & vbCrLf & Err.Description
Exit Sub
End Sub


Microsoft provides a method on how to use automation to add appoinments to Microsoft Outlook on this webpage, http://support.microsoft.com/default.aspx?scid=kb;EN-US;209963. What if someone tries to add meeting request? Actually it's really simple. If you open up the Microsoft Outlook and click on New Appoinment. You can see at the top of the Appoinment Form is a button call "Invite Attendees". If you clicked on it, the "To" field will be seen in the Appoinment Form and instantly the title of the Appoinment Form will become Meeting. To change the Appoinment to become Meeting Request, you only need this line of code:

'CHANGE APPOINMENT ITEM TO A MEETING
objAppt.MeetingStatus = Outlook.OlMeetingStatus.olMeeting

To add the attendee into the Meeting Request, you need only those code:

'ADD ATTENDEE
Dim oRecipt As Outlook.Recipient
Dim strRecipients As String

strRecipients = "Someone Name As in Global Address List or Email address"

With objAppt
'Add the recipient to the Meeting Request
Set oRecipt = .Recipients.Add(strRecipients)
oRecipt.Type = olTo

Because i am working in an organization using Microsoft Outlook. Everyone email address is inside the Global Address List. If i typed person's name according to the format in Global Address List, his or her email address will automatically insert.


Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top