I am using the following code when creating a meeting in outlook
private void ThisAddIn_Startup(object sender, EventArgs e)
{
//other code
Application.ItemSend += Application_ItemSend;
}
private void Application_ItemSend(object item, ref bool cancel)
{
if (item is MeetingItem meetingItem)
{
//some code
}
}
This functionality only works if I send a message, but if I just save the changes and close the window, this functionality does not work. I tried using this code because the application does not have a save event
private void ThisAddIn_Startup(object sender, EventArgs e)
{
//other code
Application.ItemSend += Application_ItemSend;
Application.ItemLoad += Application_ItemLoad;
}
private void Application_ItemLoad(object item)
{
if (item is MeetingItem meetingItem)
{
meetingItem.Write += (ref bool Cancel) => MeetingItem_Write(meetingItem, ref Cancel);
}
}
private void MeetingItem_Write(MeetingItem meetingItem, ref bool Cancel)
{
if (string.IsNullOrEmpty(meetingItem.Body))
{
//some code
}
}
but the write event was not triggered. I must have done something wrong. I need to implement this functionality to check if the body of the meeting is empty when it is saved. If the body is empty or null, then make changes to it.
Firstly, if you are editing items in the Calendar folder, you are dealing with AppointmentItem
objects, not MeetingItems
. MeetingItem
objects are only sent or received.
Secondly, if you want to track changes, subscribe to the Items.ItemChange
event,where Items
comes from the MAPIFolder.Items
property, and MAPIFolder
is retrieved from Application.Session.GetDefaultFolder(olFolderCalendar)
.