L.S.,
Below code is used to convert .msg files to .eml
files. This works fine, nothing wrong with this...
But, every now and then a System.NullRefferenceException error returns when converting a .msg file.
Attached a zip file with 2 .msg files. 1 converts 2 .eml
fine with below function and the other doesn't.
I think I've found the difference between the two .msg files:
- one .msg is send externally (sending mail
server is the same as the receiving server)
- one .msg is send internally
(never ‘left’ the exchange server)
Are these findings correct and why does the MailMessage object have a problem with the internally send msg file?
How can I convert the internally send .msg file to .eml?
'------code------
Public Function ConvertMsg2Eml(ByVal sMsgFileName As String) As Boolean
Try
SetAsposeLicense()
'Load mail message
Dim message As MailMessage = New MailMessage
message = MailMessage.Load(sMsgFileName, MessageFormat.Msg)
'Save to msg file
message.Save(Replace(sMsgFileName, ".msg", ".eml"), MailMessageSaveType.EmlFormat)
ConvertMsg2Eml = True
Catch ex As Exception
ConvertMsg2Eml = False
End Try
End Function
'-----end code-----