通过双击日历获取Outlook单次出现的重复日历事件

时间:2017-12-05 15:35:55

标签: outlook vsto outlook-addin

我正在创建一个Outlook插件,用于打开SharePoint日历事件以进行编辑。 SharePoint日历作为叠加层添加到Outlook。

点击series事件并编辑series时,一切正常。但是当我选择这一个(发生)时。我无法获得AppointmentItem对象的任何属性。

我已经尝试了ReadCompleteOpen个事件,但仍然有例外:

  

HRESULT的异常:0x80040108“,我无法访问   家长。看起来除了Class = 26之外,所有属性都是null   和MessageClass =“IPM.Appointment”

    private void Application_ItemLoad(object item)
    {
        _item = item;
        try
        {
            if (!(item is AppointmentItem) || !_exp.CurrentFolder.Name.Contains("Test - Conference Room ")) return;
            _warnUser = true;
            _apptItem = (AppointmentItem) item;
            _apptItem.ReadComplete += test;
            _apptItem.Open += McAI_Open;
        }
        catch (Exception ex)
        {

           var expMessage = ex.Message;
            MessageBox.Show(expMessage);
        }
    }

    private static void ThisAddIn_Shutdown(object sender, EventArgs e)
    {
        // Note: Outlook no longer raises this event. If you have code that 
        //    must run when Outlook shuts down, see https://go.microsoft.com/fwlink/?LinkId=506785
    }

    private void McAI_Open(ref bool cancel)
    {
        _warnUser = false;
        var conferenceRoom = _exp.CurrentFolder.Name;
        conferenceRoom = conferenceRoom.Replace("Test - ", "");
        if (!(_item is AppointmentItem)){return;}
        try
        {
            var g = _apptItem.IsRecurring;
            if (_apptItem != null && _exp.CurrentFolder.Name.Contains("Test") && _apptItem.Location != null)
            {
                var location = _apptItem.Location;
                var result = location.Substring(location.LastIndexOf(':') + 1);

                cancel = true;
                var sharePointItemId = int.Parse(result);                   
                var frm = new FrmCalendarSelection(
                    "<SharePointURL>" + conferenceRoom,
                    sharePointItemId);
                frm.Show();
                frm.Closed += Frm_Closed;
            }
            else if (_apptItem != null && _exp.CurrentFolder.Name.Contains("Test") && _apptItem.Location == null)
            {
                cancel = true;
                var frm = new FrmCalendarSelection(
                    "<SharePointURL>" + conferenceRoom);
                frm.Show();
                frm.Closed += Frm_Closed;
            }
        }
        catch (Exception e)
        {
            throw e;
        }

    }

0 个答案:

没有答案