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:
- Save MeetingItem to drafts before it is sent.
- Add attachment.
- 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.
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.