3
我在Item_Write事件處理程序中爲會議請求設置取消檢查,因爲如果我在Item_Send中設置取消爲true,會議窗口關閉。我想要做的是提示用戶他們有收件人,通常會使用功能區中的自定義按鈕進行處理(按鈕的詳細信息對我的問題不重要)。無論如何,當我嘗試取消Item_Write事件時,無論發送會議通知如何。無論我嘗試什麼,即使我將參數設置爲「真」,我也無法停止會議通知。如果我取消了Item_Send,那麼窗口關閉,這不是用戶想要的。我現在唯一想到的可能是requestDetailsRegion.SaveRequestDetailsToLocalOutlookItemProperties(),它將自定義表單區域字段屬性保存到AppointmentItem上定義的自定義屬性,觸發Application_Item_Load事件,並以某種方式提示Outlook發送會議邀請注意,好像它正在等待。我在Outlook 2010中運行此操作。提前感謝您。會議通知即使雖然我已設置取消在項目_Write
下面是一些示例代碼:
void Item_Write(ref bool Cancel)
{
Cancel = CancelInvite(Cancel);
}
private bool CancelInvite(bool Cancel)
{
Inspector activeInspector = Globals.ThisAddIn.Application.ActiveInspector();
WindowFormRegionCollection formRegions = Globals.FormRegions[activeInspector];
RequestDetailsFormRegion requestDetailsRegion = formRegions.RequestDetailsForm;
// Add request form details to meeting item.
requestDetailsRegion.SaveRequestDetailsToLocalOutlookItemProperties();
// Checking if there's an incomplete form request pending submission
if (requestDetailsRegion.txtFileName_Hidden.TextLength == 0 &&
appointmentItem != null && appointmentItem.MeetingStatus != OlMeetingStatus.olMeetingCanceled)
{
Persons meetingRecipients = new Persons();
foreach (Outlook.Recipient recipient in appointmentItem.Recipients)
if (recipient.Address != activeInspector.Session.CurrentUser.Address)
meetingRecipients.Add(new MeetingRecipient(recipient));
if (meetingRecipients.ContainsSpecialRecipients)
{
CustomDialog customDialog = new CustomDialog();
customDialog.OkButtonText = messageBoxTextStatusOK;
customDialog.CancelButtonText = messageBoxTextStatusCancel;
DialogResult dialogResult = customDialog.ShowDialog();
if (dialogResult == DialogResult.Cancel)
{
Cancel = true;
}
else
{
Cancel = false;
}
customDialog.Close();
}
}
return Cancel;
}
public void SaveRequestDetailsToLocalOutlookItemProperties()
{
if (this.OutlookItem is Outlook.AppointmentItem)
{
Outlook.AppointmentItem appointmentItem = (Outlook.AppointmentItem)this.OutlookItem;
// Checking if organizer already cancelled meeting. If so, then no need to update apppointment item properties.
if (appointmentItem.MeetingStatus != Outlook.OlMeetingStatus.olMeetingCanceled)
{
appointmentItem.ItemProperties[RequestSubmitted].Value = chkSubmitted.Checked; // Hidden
appointmentItem.ItemProperties[Filename].Value = txtFileName_Hidden.Text; // Hidden
appointmentItem.ItemProperties[ReasonForVisit].Value = txtReason.Text;
// SPARING SIMILAR LINES OF CODE
...
chkSaved.Checked = true;
}
}
感謝您的答覆梅德。我其實是。我要更新代碼示例。儘管將「取消」設置爲「真」,它仍然會發生。哪一個是正確的問題,這使得我一開始就打屁股。 – jive137 2013-04-10 22:02:36
只是爲了澄清當我說「發生......」時,儘管設置了「取消」爲真,發送會議通知仍會發生。再次感謝。 – jive137 2013-04-10 22:45:21
什麼是您的Application.ItemSend事件處理程序? – 2013-04-11 17:08:55