Platform SDK: Exchange 2000 Server

Adding Attachments to Appointments and Meetings

[This is preliminary documentation and subject to change.]

You can add attachments to appointments and meetings. For example, you could attach an image of a map to a meeting to show where the meeting is located.

Attachments are added using the Attachments collection of the Appointment object. Attachments are saved with the Appointment object in the Web Store.

To add an attachment to an appointment or meeting

  1. Create the Appointment object and set its properties.
  2. Create the attachment body part by calling the Add method on the attachments collection.
  3. Set the content type and content transfer encoding fields of the body part.
  4. Get the default stream from the attachment body part.
  5. Load the file being attached into the default stream, and save it back to the attachment body part.
  6. For meetings, create a calendar message, add attendees, and send the meeting request.
  7. Save the appointment or meeting to the organizer's calendar folder (optional).

The following code example shows how to add the attachment d:\maps\directions.gif to a meeting.

[Visual Basic]
Dim iAppt       As New Appointment
Dim CalendarURL As String
Dim iCalMsg     As CalendarMessage
Dim iAttendee   As New Attendee
Dim Config      As New Configuration
Dim iBp         As IBodyPart
Dim Stm         As Stream
Dim Flds        As Fields

CalendarURL = "file://./backofficestorage/" & DomainName & "/MBX/" & UserName & "/calendar/"

'Set the configuration fields
Config.Fields(cdoSendEmailAddress) = UserName & "@" & DomainName
Config.Fields.Update
iAppt.Configuration = Config

'Set the meeting properties
iAppt.StartTime = #10/27/1999 1:30:00 PM#
iAppt.EndTime = #10/27/1999 2:30:00 PM#
iAppt.Subject = "Department Off-Site"
iAppt.Location = "617 Main St."
iAppt.TextBody = "Lunch will be served!  See the attached map for directions."

'Create a new attachment body part
Set iBp = iAppt.Attachments.Add

'Set the fields for the attachment
Set Flds = iBp.Fields
Flds.Item("urn:schemas:mailheader:content-type") = "image/gif; name=directions.gif"
Flds.Item("urn:schemas:mailheader:content-transfer-encoding") = "base64"
Flds.Update

'Get the stream interface on the body part
Set Stm = iBp.GetDecodedContentStream

'Load the attachment file into the stream and flush
'  the stream to save it back to the body part
Stm.LoadFromFile ("d:\maps\directions.gif")
Stm.Flush

'Add an attendee
Set iAttendee = iAppt.Attendees.Add
iAttendee.Address = "someone@" & DomainName
iAttendee.Role = cdoRequiredParticipant

'Create the calendar message and send it
Set iCalMsg = iAppt.CreateRequest
iCalMsg.Message.Send

'Save the meeting to the organizer's calendar
iAppt.DataSource.SaveToContainer CalendarURL