Extracting Start/End date from calendar...

Aug 9, 2012 at 12:39 PM

Hi,

I need to extract start & end date time from IMessage (Calendar), how to do that ?

foreach (IMessage message in f.Messages)
{
     message.ReadProperty(??);
}

Thanks in advance.

Aug 13, 2012 at 5:16 AM

Found TagID,

PidTagICalendarStartTime, PidLidAppointmentStartDate

but not able to do using this id.

(DateTime)PropertyHelper.GetTimeProperty(message.ReadProperty(0x10C3));

(DateTime)PropertyHelper.GetTimeProperty(message.ReadProperty(0x00008212));

it thow exception....

Developer
Aug 17, 2012 at 12:30 AM

What is the exception message?  I think that would be a good place to start.

There's no guarantee that the property exists on a particular message (even if the exchange documentation says a property MUST be present on a certain message class).  Are you first checking the property exists?  Also, "0x00008212" looks like a LongId which means it's a named property, not a regular one.  You have to lookup that named property in the NameIDMap first, to get an actually property you can query for.  There's a change that 0x8212 would actually exist and return a property that you're not expecting.

If the property id is less than 0x8000, then you can just read the property as normal IF it exists (message.PropertyExists).  If you try and read a property that doesn't exist, it will throw an exception.  For property ids that are greater than 0x8000, get the INameIDMap from IPst.  Check to see if the named property exists (INameIdMap.PropertyExists(Guid, int/string)), and if it does, look it up to get the correct id to read from the message (INameIdMap.Lookup(Guid, int/string)).  You can use the PropId it returns to read it from the message.

In the case you have more questions regarding named properties, please refer to [MS-PST] Section 2.4.2.2: http://msdn.microsoft.com/en-us/library/ff386230(v=office.12).aspx

 

Thanks,
Christopher

Aug 17, 2012 at 7:16 AM

Hi Christopher,

i have solved this with same way (message.PropertyExists).

Thanks for reply.