We are having some issues when attempting to save certain Exchange Item types with HTML Body Content. We are attempting to create Exchange items in the following manner:
First, we are creating an MAPI Item and setting the item’s the body and body type appropriately.
var body = GetValue<MessageBody>(item, ItemSchema.Body);
if (body != null && body.Text != null)
{
mapiItem.SetBodyContent(body.Text, body.BodyType == BodyType.HTML ? BodyContentType.Html : BodyContentType.PlainText);
}
We are then attempting to save the item to a file.
public void SaveToMsgFile(MapiMessageItemBase item, string msgFile)
{
if (item is MapiMessage)
{
(item as MapiMessage).Save(msgFile);
return;
}
if (item is MapiContact)
{
(item as MapiContact).Save(msgFile, ContactSaveFormat.Msg);
return;
}
if (item is MapiCalendar)
{
(item as MapiCalendar).Save(msgFile, AppointmentSaveFormat.Msg);
return;
}
if (item is MapiTask)
{
(item as MapiTask).Save(msgFile, TaskSaveFormat.Msg);
return;
}
}
This works fine so long as the MAPI item is an Email Message; The body type is preserved correctly. However, when attempting to use any other item type (Task, Calendar, Contact, Meeting, etc) the body appears to always revert to Plain Text.
Is there a way to save all items with the correct body type?