The info below was produced using Aspose.Email for .NET version 18.5 in my test program
1. I initialized the Aspose.Email license with no problem
2. I saved the info for first message and the message in the “Sent Items” folder to disk file with the following code.
Dim mm As MailMessage = Nothing
Dim message As Mapi.MapiMessage = Nothing
Dim Conv_opt As MailConversionOptions = Nothing
Conv_opt = New MailConversionOptions()
Conv_opt.PreserveEmbeddedMessageFormat = True
Dim _savetype As MailMessageSaveType = MailMessageSaveType.OutlookMessageFormatUnicode
Dim Saveopt As SaveOptions = SaveOptions.CreateSaveOptions(_savetype)
message = _PST.ExtractMessage(MsgInfo).ToMapiMessageItem
mm = message.ToMailMessage(Conv_opt) '_PST.ExtractMessage(MsgInfo).ToMailMessage
Debug.Print(String.Format("{0}Subject : {1}", vbNewLine, message.Subject))
If message.GetPropertyDateTime(Mapi.MapiPropertyTag.PR_CREATION_TIME) IsNot Nothing Then
Debug.Print(String.Format("PR_CREATION_TIME : {0:u}", CDate(message.GetPropertyDateTime(Mapi.MapiPropertyTag.PR_CREATION_TIME)).ToUniversalTime))
End If
If message.GetPropertyDateTime(Mapi.MapiPropertyTag.PR_EXPIRY_TIME) IsNot Nothing Then
Debug.Print(String.Format("PR_EXPIRY_TIME : {0:u}", CDate(message.GetPropertyDateTime(Mapi.MapiPropertyTag.PR_EXPIRY_TIME)).ToUniversalTime))
End If
If message.GetPropertyDateTime(Mapi.MapiPropertyTag.PR_LAST_MODIFICATION_TIME) IsNot Nothing Then
Debug.Print(String.Format("PR_LAST_MODIFICATION_TIME : {0:u}", CDate(message.GetPropertyDateTime(Mapi.MapiPropertyTag.PR_LAST_MODIFICATION_TIME)).ToUniversalTime))
End If
If message.GetPropertyDateTime(Mapi.MapiPropertyTag.PR_CLIENT_SUBMIT_TIME) IsNot Nothing Then
Debug.Print(String.Format("PR_CLIENT_SUBMIT_TIME : {0:u}", CDate(message.GetPropertyDateTime(Mapi.MapiPropertyTag.PR_CLIENT_SUBMIT_TIME)).ToUniversalTime))
End If
If IsDate(message.DeliveryTime) AndAlso (Year(message.DeliveryTime) > 1900 And Year(message.DeliveryTime) < 3000) Then
Debug.Print(String.Format("DeliveryTime : {0:u}", CDate(message.DeliveryTime).ToUniversalTime))
End If
' save this message to disk in msg format
Try
If Directory.Exists(_outDir) = False Then Directory.CreateDirectory(_outDir)
Dim _outputfilename As String = Path.Combine(_outDir, String.Format(msgfilename, cnt))
message.Save(_outputfilename, SaveOptions.CreateSaveOptions(_savetype))
Catch ex As Exception
#If DEBUG Then
MsgBox(String.Format(“Error Saving Message # {0}{1} Error : {2}”, cnt, vbNewLine, ex.Message))
#End If
End Try
3. I opened the saved msg file with code in a procedure called LoadMsgGoodWay with the following results.
Here's the code:
Public Sub LoadMsgGoodWay(ByVal filename As String)
Dim mm As MailMessage = Nothing
Dim message As Mapi.MapiMessage = Nothing
Dim Conv_opt As MailConversionOptions = Nothing
Conv_opt = New MailConversionOptions()
Conv_opt.PreserveEmbeddedMessageFormat = True
Try
Debug.Print("Loading eMail Using Goodway")
' Detect file format and Gets the detected load format
Dim info As FileFormatInfo = Tools.FileFormatUtil.DetectFileFormat(filename)
Debug.Print(String.Format("The message format is: {0}", info.FileFormatType.ToString))
Dim _loadoptions As LoadOptions = Nothing
Select Case info.FileFormatType
Case Aspose.Email.FileFormatType.Eml
_loadoptions = New EmlLoadOptions
Case Aspose.Email.FileFormatType.Emlx
_loadoptions = New EmlxLoadOptions
Case Aspose.Email.FileFormatType.Msg
_loadoptions = New MsgLoadOptions
Case Aspose.Email.FileFormatType.Tnef
_loadoptions = New TnefLoadOptions
End Select
message = Mapi.MapiMessage.FromFile(filename)
mm = message.ToMailMessage(Conv_opt)
Debug.Print(String.Format("{0}Subject : {1}", vbNewLine, message.Subject))
If message.GetPropertyDateTime(Mapi.MapiPropertyTag.PR_CREATION_TIME) IsNot Nothing Then
Debug.Print(String.Format("PR_CREATION_TIME : {0:u}", CDate(message.GetPropertyDateTime(Mapi.MapiPropertyTag.PR_CREATION_TIME)).ToUniversalTime))
End If
If message.GetPropertyDateTime(Mapi.MapiPropertyTag.PR_EXPIRY_TIME) IsNot Nothing Then
Debug.Print(String.Format("PR_EXPIRY_TIME : {0:u}", CDate(message.GetPropertyDateTime(Mapi.MapiPropertyTag.PR_EXPIRY_TIME)).ToUniversalTime))
End If
If message.GetPropertyDateTime(Mapi.MapiPropertyTag.PR_LAST_MODIFICATION_TIME) IsNot Nothing Then
Debug.Print(String.Format("PR_LAST_MODIFICATION_TIME : {0:u}", CDate(message.GetPropertyDateTime(Mapi.MapiPropertyTag.PR_LAST_MODIFICATION_TIME)).ToUniversalTime))
End If
If message.GetPropertyDateTime(Mapi.MapiPropertyTag.PR_CLIENT_SUBMIT_TIME) IsNot Nothing Then
Debug.Print(String.Format("PR_CLIENT_SUBMIT_TIME : {0:u}", CDate(message.GetPropertyDateTime(Mapi.MapiPropertyTag.PR_CLIENT_SUBMIT_TIME)).ToUniversalTime))
End If
If IsDate(message.DeliveryTime) AndAlso (Year(message.DeliveryTime) > 1900 And Year(message.DeliveryTime) < 3000) Then
Debug.Print(String.Format("DeliveryTime : {0:u}", CDate(message.DeliveryTime).ToUniversalTime))
End If
Catch ex As Exception
#If DEBUG Then
Stop
#End If
End Try
End Sub
Debug output:
Loading eMail Using Goodway
The message format is: Msg
Subject : Cavell Energy Corporation
PR_CREATION_TIME : 2010-06-18 22:41:09Z
PR_LAST_MODIFICATION_TIME : 2010-06-18 22:41:09Z
PR_CLIENT_SUBMIT_TIME : 2001-10-30 20:01:00Z
DeliveryTime : 2001-10-30 20:01:00Z
4. I opened the saved msg file with code in a procedure called LoadMsgBadWay with the following results.
Here's the code:
Public Sub LoadMsgBadWay(ByVal filename As String)
Dim mm As MailMessage = Nothing
Dim message As Mapi.MapiMessage = Nothing
Try
Debug.Print("Loading eMail Using Badway")
' Detect file format and Gets the detected load format
Dim info As FileFormatInfo = Tools.FileFormatUtil.DetectFileFormat(filename)
Debug.Print(String.Format("The message format is: {0}", info.FileFormatType.ToString))
Dim _loadoptions As LoadOptions = Nothing
Select Case info.FileFormatType
Case Aspose.Email.FileFormatType.Eml
_loadoptions = New EmlLoadOptions
Case Aspose.Email.FileFormatType.Emlx
_loadoptions = New EmlxLoadOptions
Case Aspose.Email.FileFormatType.Msg
_loadoptions = New MsgLoadOptions
Case Aspose.Email.FileFormatType.Tnef
_loadoptions = New TnefLoadOptions
End Select
mm = MailMessage.Load(filename, _loadoptions)
message = Mapi.MapiMessage.FromMailMessage(mm)
Debug.Print(String.Format("{0}Subject : {1}", vbNewLine, message.Subject))
If message.GetPropertyDateTime(Mapi.MapiPropertyTag.PR_CREATION_TIME) IsNot Nothing Then
Debug.Print(String.Format("PR_CREATION_TIME : {0:u}", CDate(message.GetPropertyDateTime(Mapi.MapiPropertyTag.PR_CREATION_TIME)).ToUniversalTime))
End If
If message.GetPropertyDateTime(Mapi.MapiPropertyTag.PR_EXPIRY_TIME) IsNot Nothing Then
Debug.Print(String.Format("PR_EXPIRY_TIME : {0:u}", CDate(message.GetPropertyDateTime(Mapi.MapiPropertyTag.PR_EXPIRY_TIME)).ToUniversalTime))
End If
If message.GetPropertyDateTime(Mapi.MapiPropertyTag.PR_LAST_MODIFICATION_TIME) IsNot Nothing Then
Debug.Print(String.Format("PR_LAST_MODIFICATION_TIME : {0:u}", CDate(message.GetPropertyDateTime(Mapi.MapiPropertyTag.PR_LAST_MODIFICATION_TIME)).ToUniversalTime))
End If
If message.GetPropertyDateTime(Mapi.MapiPropertyTag.PR_CLIENT_SUBMIT_TIME) IsNot Nothing Then
Debug.Print(String.Format("PR_CLIENT_SUBMIT_TIME : {0:u}", CDate(message.GetPropertyDateTime(Mapi.MapiPropertyTag.PR_CLIENT_SUBMIT_TIME)).ToUniversalTime))
End If
If IsDate(message.DeliveryTime) AndAlso (Year(message.DeliveryTime) > 1900 And Year(message.DeliveryTime) < 3000) Then
Debug.Print(String.Format("DeliveryTime : {0:u}", CDate(message.DeliveryTime).ToUniversalTime))
End If
Catch ex As Exception
#If DEBUG Then
Stop
#End If
End Try
End Sub
Debug output:
Loading eMail Using Badway
The message format is: Msg
Subject : Cavell Energy Corporation(Aspose.Email Evaluation) ???
PR_CREATION_TIME : 2018-07-05 13:39:38Z
PR_LAST_MODIFICATION_TIME : 2018-07-05 13:39:38Z
PR_CLIENT_SUBMIT_TIME : 2001-10-30 20:01:00Z
DeliveryTime : 2001-10-30 20:01:00Z
Why does it say “Aspose.Email Evaluation”? Since the license loaded ok.
I did find what is causing the problem.
When I use these 2 lines (from Badway)
mm = MailMessage.Load(filename, _loadoptions)
message = Mapi.MapiMessage.FromMailMessage(mm)
It produces bad dates
When I use these 2 lines (from Goodway)
message = Mapi.MapiMessage.FromFile(filename)
mm = message.ToMailMessage(Conv_opt)
It’s good
Why???