1
votes

I am working on my plugin and faced with the next problem: it looks like that MeetingItems works differently, then MailItems.

What I need to do:

  1. Save MeetingItem to drafts before it is sent.
  2. Add attachment.
  3. Send it.

1 To save MeetingItem to drafts:

(Item as MeetingItem).GetAssociatedAppointment(false).GetInspector.Close(OlInspectorClose.olSave);

It works.

2. Add attachment.

Attaches = (Item as MeetingItem).GetAssociatedAppointment(false).Attachments;
Attaches.Add(...).

It works as well.

3. Send mail.

Try1:

(Item as MeetingItem).Send();  << it doesn't work.

Try2:

AppointmentItem appItem = Item.GetAssociatedAppointment(false);
appItem.Send(); << It works. But MeetingItem is still in drafts folder (???)
Item.Delete(); << Moved to deleted folder, and can't delete permanently.

It think on the 3rd step I am doing something wrong. Do you know how to send MeetingItem correctly?

Update:

When I send MeetingItem, Outlook asks me "Would you like to update your own calendar now". If I press yes, then Application_ItemSend callback is not called at all, so I can't add my attachment then. I am confused what is going on there.

Outlook message box

Update 2:

It appears, that when I add attachment already incoming messages, then I should use

(Item as MailItem).Attachments.Add(...)

but when I am sending mail, I should use

(Item as MailItem).GetAssociatedAppointment(false).Attachments.Add(...)

It is confusing.

2

2 Answers

0
votes

Meeting items are not designed to be saved or manipulated by the users - they are created automatically when an appointment is sent. You really need to add attachments to the appointment itself. If you still only want them on the meeting item only, you canprocess Application.ItemSend event and add the attachments to the MeetingItem object passed to your event handler.

0
votes

There is no need to use the GetAssociatedAppointment method of the MeetingItem class. You can get the an instance of the Inspector class directly by calling the GetInspector property of the MeetingItem class. The same rule applies to other properties and methods you need to call - Send, Attachments and etc.

When you create a meeting request programmatically, you first create an AppointmentItem object instead of a MeetingItem object. To indicate the appointment is a meeting, set the MeetingStatus property of the AppointmentItem object to olMeeting . To send the meeting request, apply the Send method to that AppointmentItem object.