I have a case where I am creating a new MapiMessage and setting its properties.
I have added this MapiMessage to a folder on the PST store.
Now after adding this Message, I want to know the size of this Message on the Pst store. I am not able to get this info.
I tried,
-
Getting the size from the MapiMessage object itself through the MapiPropertyTag.PR_MESSAGE_SIZE on .Properties. Always get this as zero.
-
Notice that MessageInfo also has a Properties property which returns the size of the message. I am getting this MessageInfo object by calling .GetContents() and comparing the EntryIdString property with the itemID.
Approach #2, will be very slow because we are doing a linear search to find the message that we just added to the PstStore.
Is there a way to fetch the email size directly from MapiMessage object.
Sample code:
Blockquote
// Assuming parentFolder of type FolderInfo already exits
var mapiMessage = new MapiMessage();
//Updates to mapiMessage
//The below lines returns nil, hence size is nil
var size = mapiMessage.Properties[MapiPropertyTag.PR_MESSAGE_SIZE]
//This works
var itemId = parentFolder.AddMessage(mapiMessage)
var messageInfoCollection = parentFolder.GetContents();
MessageInfo matchedMessageInfo;
foreach(MessageInfo msg in messageInfoCollection) {
if msg.EntryIdString == itemId {
size = msg.Properties[MapiPropertyTag.PR_MESSAGE_SIZE];
break;
}
}
Issue:
To be able to use a MailQuery to search on the folder, we need the InternetMessageId of the MapiMessage to match with the MessageId during query. But the mapiMessage object created above doesn’t have InternetMessageId nd hence we are unable to query the folderInfo for the parentFolder.
Is there a way to get the size of the email given the MapiMessage object?