We just released Aspose.Network v 4.7 which contains fixes for eml to msg conversion in 64-bit Windows. Please download from http://www.aspose.com/community/files/51/file-format-components/aspose.network-for-.net/entry175281.aspx and try with the new dlls.
I just tested your sample code with it in 64-bit Windows and it worked fine. If you still have issues, please copy the exception message and stack trace here.
We still got a problem with conversion of mail messages. With the code below we try to convert a msg formatted mail to RFC 822 format and back to msg format. Now the code which works with Aspose.Network 4.6.0.1 doesn’t work any more with version 4.7.0.8. The code fails at the underlined line with the following error description. The error occurs with any msg formatted mail on 32 bit and 64 bit windows platforms.
Best Regards
Volker Roeser
bei System.String.InternalSubStringWithChecks(Int32 startIndex, Int32 length, Boolean fAlwaysCopy)
bei System.String.Substring(Int32 startIndex, Int32 length)
bei Aspose.Network.Outlook.MapiMessage.xbe8fa87f38748b7c(MapiAttachmentCollection xb8b986a36a564367, MapiPropertyStream xebd3f90832eab048, Attachment xdd361a2e023253e5, OutlookMessageFormat x5786461d089b10a0)
bei Aspose.Network.Outlook.MapiMessage.xaa71394a9a765151(MailMessage x1f25abf5fb75e795, MapiMessage xa773d6b986f6bdbb)
bei Aspose.Network.Outlook.MapiMessage.FromMailMessage(MailMessage message)
bei Aspose.Network.Mail.MailMessage.Save(Stream stream, MessageFormat format)
bei WindowsApplication2.Form1.ConvertEmailFormat(Stream pStream, MessageFormat pInputFormat, MessageFormat pOutputFormat)
private void button1_Click(object sender, EventArgs eventArgs)
{
OpenFileDialog dlg = null;
try
{
dlg = new OpenFileDialog();
dlg.Multiselect = false;
dlg.Filter = "Outlook-Nachrichtenformat (*.msg)|*.msg|RFC 822 Format (*.eml)|*.eml|"
+ "Alle Dateien (*.*)|*.*";
if (dlg.ShowDialog() != DialogResult.OK)
return;
textBoxFilename.Text = dlg.FileName;
MailMessage mailMessage = null;
if (Path.GetExtension(dlg.FileName).ToLower().Equals(".msg"))
mailMessage = MailMessage.Load(dlg.OpenFile(), MessageFormat.Msg);
else
mailMessage = MailMessage.Load(dlg.OpenFile());
Stream stream = new MemoryStream();
mailMessage.Save(stream);
stream.Position = 0;
//... Save the RFC 822 formatted mail to a stream wich will be saved into database
//... load the stream from database and change the mail format back to msg format
stream = ConvertEmailFormat(stream, MessageFormat.Eml, MessageFormat.Msg);
}
catch (Exception e)
{
MessageBox.Show(e.Message, "Fehler", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
private Stream ConvertEmailFormat(Stream pStream, MessageFormat pInputFormat, MessageFormat pOutputFormat)
{
Stream stream = null;
try
{
pStream.Position = 0;
MailMessage mailMessage = MailMessage.Load(pStream, pInputFormat);
stream = new MemoryStream();
mailMessage.Save(stream, pOutputFormat);
stream.Position = 0;
}
catch (Exception e)
{
throw new MailArchiveException(string.Format("Fehler beim Umwandeln der E-Mail in das"
+ "{0}-Dateiformat", pOutputFormat.ToString()), e);
}
return stream;
}
As i wrot in my prior post: (…) we try to convert a msg formatted mail to RFC 822 format and back to msg format. (…). The error occurs with any msg formatted mail on 32 bit and 64 bit windows platforms.
If you run the code i provided with the previous post you should always run with any msg formatted mail in the error i described. (I attach a simple msg file which you can use for testing)
Best Regards
Volker Roeser
Die Länge darf nicht kleiner als 0 (null) sein. Parametername: length
bei System.String.InternalSubStringWithChecks(Int32 startIndex, Int32 length, Boolean fAlwaysCopy)
bei System.String.Substring(Int32 startIndex, Int32 length)
bei Aspose.Network.Outlook.MapiMessage.xbe8fa87f38748b7c(MapiAttachmentCollection xb8b986a36a564367, MapiPropertyStream xebd3f90832eab048, Attachment xdd361a2e023253e5, OutlookMessageFormat x5786461d089b10a0)
bei Aspose.Network.Outlook.MapiMessage.xaa71394a9a765151(MailMessage x1f25abf5fb75e795, MapiMessage xa773d6b986f6bdbb)
bei Aspose.Network.Outlook.MapiMessage.FromMailMessage(MailMessage message)
bei Aspose.Network.Mail.MailMessage.Save(Stream stream, MessageFormat format)
bei WindowsApplication2.Form1.ConvertEmailFormat(Stream pStream, MessageFormat pInputFormat, MessageFormat pOutputFormat)