Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Importing ics file to an Outlook.AppointmentItem

I have an Outlook 2007 add-in that is trying to import ics files into Outlook.AppointmentItem objects so that I can read attributes about certain appointments. Currently I am not able to read the ics back into memory. Any suggestions on what I am doing wrong.

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*

Thanks

like image 450
Rick Make Avatar asked Mar 04 '10 14:03

Rick Make


People also ask

Can I import an ics file into Outlook?

In Outlook, select File > Open & Export > Import/Export. In Import and Export Wizard box, select Import an iCalendar (. ics)orvCalendar file (. vcs),and then Next.


1 Answers

I think the problem is due to the fact that AppointmentItem and MeetingItem are different classes so you cannot convert one to another directly. Could you try the following and check if it works?

var item = app.Session.OpenSharedItem(@"C:\meeting.ics") as Outlook.AppointmentItem;
like image 71
Alberto Avatar answered Oct 13 '22 07:10

Alberto