首页 > 解决方案 > C# -> COM -> 更改约会 -> 填充 Start 和 End 时出现异常 -> 对象不支持此方法

问题描述

我想更改现有约会。为此,我通过以下方式搜索现有约会:

                Outlook.Items foundItems = outlookItems.Restrict(filter);

            if (foundItems != null)
            {
                foreach (var item in foundItems)
                {
                    if (item is Outlook.AppointmentItem)
                    {
                        Outlook.AppointmentItem aptItem = item as Outlook.AppointmentItem;

                        aptItem.Start = start;
                    }
                }
            }

或者:

foundItem = outlookItems.Find(filter) as Outlook.AppointmentItem;
if (foundItem != null)
{foundItem.Start = start}

无论如何,如果我想填写 appoitnment.Start 属性,它会遇到这个异常:

“该对象不支持此方法。”

我的想法是这是一个会议,所以我尝试了以下方法:

                Outlook.MeetingItem foundItem = outlookItems.Find(filter) as Outlook.MeetingItem;

            Outlook.AppointmentItem aptItem = foundItem.GetAssociatedAppointment(false);

但是foundItem为空,也没有MeetingItem ...

有人有想法吗?

标签: c#outlookcomoutlook-object-model

解决方案


好的,我自己找到了一个解决方案:

在定期约会或会议的情况下,我从recurrencePattern 中填写属性StartTimeEndTime :

                            newRecurrencePatternForOutlook.StartTime = start;
                        newRecurrencePatternForOutlook.EndTime = end;

但是为什么 AppointmentItem 的 Start 和 End 属性不存在,我无法回答。

也许这会帮助某人


推荐阅读