We’re using MailMessage
to load up a MIME file then Save
with DefaultMsgUnicode
to save it as a MSG file.
We find the date
specified in the MIME file becomes the PR_MESSAGE_DELIVERY_TIME of the MSG but the PR_CLIENT_SUBMIT_TIME of the MSG is set to the current date/time.
This is a fragment of the code we’re using:
var mimeMessage = MailMessage.Load(mimeMemoryStream, new EmlLoadOptions());
using var msgMemoryStream = new MemoryStream();
mimeMessage.Save(msgMemoryStream, SaveOptions.DefaultMsgUnicode);
Is this always going to be the case (is there any scenario where PR_CLIENT_SUBMIT_TIME will be set for a MIME message) or can we influence the behaviour? If it’s always the case, we’ll copy PR_MESSAGE_DELIVERY_TIME to PR_CLIENT_SUBMIT_TIME but don’t want to risk overwriting anything that may have come from MIME.
@oliseaman
When converting a MIME file to an MSG file using the MailMessage
class, the PR_CLIENT_SUBMIT_TIME
property is typically set to the current date and time. This behavior occurs because the Aspose.Email library does not automatically populate the PR_CLIENT_SUBMIT_TIME
from the MIME file. Instead, it defaults to the current timestamp when saving the message as an MSG file.
If you want to ensure that the PR_CLIENT_SUBMIT_TIME
reflects the PR_MESSAGE_DELIVERY_TIME
from the MIME file, you can manually copy the value after loading the MIME message. Here’s how you can do that:
var mimeMessage = MailMessage.Load(mimeMemoryStream, new EmlLoadOptions());
using var msgMemoryStream = new MemoryStream();
mimeMessage.Save(msgMemoryStream, SaveOptions.DefaultMsgUnicode);
// After saving, copy PR_MESSAGE_DELIVERY_TIME to PR_CLIENT_SUBMIT_TIME
var mapiMessage = MapiMessage.FromMailMessage(mimeMessage);
mapiMessage.ClientSubmitTime = mapiMessage.MessageDeliveryTime; // Copy the delivery time
This way, you can ensure that the PR_CLIENT_SUBMIT_TIME
is set to the same value as PR_MESSAGE_DELIVERY_TIME
, avoiding any potential issues with overwriting important data from the MIME file.
Currently, there is no built-in option in the Aspose.Email library to automatically set PR_CLIENT_SUBMIT_TIME
from the MIME file during the conversion process. Therefore, your approach of manually copying the value is a valid solution.
If you have further questions or need additional assistance, feel free to ask!