I have a bit of code that can save a newly created MapiMessage to disk as an appointment (because it IS an appointment), and recast it:
Appointment ConvertMapiMessageToAppointment(MapiMessage mapiMessage)
{
var mapiCalendar = (MapiCalendar)mapiMessage.ToMapiMessageItem();
using (var ms = new MemoryStream())
{
mapiCalendar.Save(ms);
ms.Position = 0;
var appointment = Appointment.Load(ms);
return appointment;
}
}
This works very well for the most part, as long as I don’t try to create that appointment in EWS, because the application will generate an exception.
Alternatively, if I use this bit of code to make an appointment:
Appointment appointment = new Appointment(
“Meeting Room 3 at Office Headquarters”, // Location
“Monthly Meeting”, // Summary
“Please confirm your availability.”, // Description
new DateTime(2011, 2, 8, 13, 0, 0), // Start date
new DateTime(2011, 2, 8, 14, 0, 0), // End date
"from@domain.com", // Organizer
"attendees@domain.com"); // Attendees
…instead of loading<!–[if gte mso 9]>
<w:WordDocument>
<w:View>Normal</w:View>
<w:Zoom>0</w:Zoom>
<w:TrackMoves/>
<w:TrackFormatting/>
<w:PunctuationKerning/>
<w:ValidateAgainstSchemas/>
<w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
<w:IgnoreMixedContent>false</w:IgnoreMixedContent>
<w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
<w:DoNotPromoteQF/>
<w:LidThemeOther>EN-US</w:LidThemeOther>
<w:LidThemeAsian>X-NONE</w:LidThemeAsian>
<w:LidThemeComplexScript>X-NONE</w:LidThemeComplexScript>
<w:Compatibility>
<w:BreakWrappedTables/>
<w:SnapToGridInCell/>
<w:WrapTextWithPunct/>
<w:UseAsianBreakRules/>
<w:DontGrowAutofit/>
<w:SplitPgBreakAndParaMark/>
<w:EnableOpenTypeKerning/>
<w:DontFlipMirrorIndents/>
<w:OverrideTableStyleHps/>
</w:Compatibility>
<m:mathPr>
<m:mathFont m:val=“Cambria Math”/>
<m:brkBin m:val=“before”/>
<m:brkBinSub m:val="–"/>
<m:smallFrac m:val=“off”/>
<m:dispDef/>
<m:lMargin m:val=“0”/>
<m:rMargin m:val=“0”/>
<m:defJc m:val=“centerGroup”/>
<m:wrapIndent m:val=“1440”/>
<m:intLim m:val=“subSup”/>
<m:naryLim m:val=“undOvr”/>
</m:mathPr></w:WordDocument>
<![endif]–><!–[if gte mso 10]>
<![endif]–> it from disk, I can create this one in EWS with no problems.
I have included a sample appointment and sample code to demonstrate the issue.