14

我有一个 Outlook 2007 加载项,它试图将 ics 文件导入 Outlook.AppointmentItem 对象,以便我可以读取有关某些约会的属性。目前我无法将 ics 读回内存。关于我做错了什么的任何建议。

Outlook.Application app = new Outlook.Application();
var item = app.Session.OpenSharedItem("C:\\meeting.ics") as Outlook.AppointmentItem;
string meetingBody = item.Body; //<--*my item is null*

谢谢

4

3 回答 3

1

这可能是因为这个 ics 文件只显示了一个会议项目而不是一个约会项目。据我所知,您可以尝试使用以下代码,

Outlook.MeetingItem item = app.Session.OpenSharedItem(@"C:\SomeMeeting.ics") as Outlook.MeetingItem;

如果您对此有任何疑虑,请随时跟进。

http://social.msdn.microsoft.com/Forums/en-GB/vsto/thread/f98bfa75-a995-403e-a3fc-5be3a37511d7

于 2012-11-09T05:27:40.863 回答
1

我认为问题是由于AppointmentItemMeetingItem是不同的类,因此您不能直接将一个转换为另一个。您可以尝试以下方法并检查它是否有效?

var item = app.Session.OpenSharedItem(@"C:\meeting.ics") as Outlook.AppointmentItem;
于 2011-12-08T09:27:25.777 回答
1

只需检查其类型

            Set attObj = ns.OpenSharedItem(strFilename)                

            Select Case TypeName(attObj)
                Case "MeetingItem"
                    Dim miNewMeetingItem As Outlook.MeetingItem
                    Set miNewMeetingItem = attObj
                    ...
                Case "AppointmentItem"
                    Dim miNewAppointmentItem As Outlook.AppointmentItem
                    Set miNewAppointmentItem = attObj
                    ...
                Case Else
                    Dim miNew As Outlook.MailItem
                    Set miNew = attObj
                    ...
            End Select

            Set attObj = Nothing
于 2015-01-09T17:45:32.353 回答