Hello all!
I try to convert a eml-forrmatted mail from stream into a msg-forrmatted mail and save it to an other stream with Aspose.Network. The code runs in context of a webserver. In debug-mode on windows xp sp3 (outlook is installed) using cassini as webserver it works. In release (any cpu) on windows 2003 server 64-bit (outlook isn't installed) using iis 6 as webserver it fails. I try it in two different ways and in both cases the code below fails at the underlined line with a null pointer exception while the input parameters were valid object references.
Can you please provide an explanation and/or solution to this issue?
Thanks
Volker Roeser
public static Stream ConvertMailFormat(Stream pStream, MessageFormat pInputFormat, MessageFormat pOutputFormat)
{
Stream stream = null;
try
{
pStream.Position = 0;
MailMessage mailMessage = MailMessage.Load(pStream, pInputFormat);
stream = new MemoryStream();
if (pInputFormat.GetType().Equals(MessageFormat.Eml.GetType())
&& pOutputFormat.GetType().Equals(MessageFormat.Msg.GetType()))
{
MapiMessage mapiMessage = MapiMessage.FromMailMessage(mailMessage);
mapiMessage.Save(stream);
}
else if (pInputFormat.GetType().Equals(MessageFormat.Msg.GetType())
&& pOutputFormat.GetType().Equals(MessageFormat.Eml.GetType()))
{
mailMessage.Save(stream, pOutputFormat);
}
stream.Position = 0;
}
catch (Exception)
{
throw
}
return stream;
}
public static Stream ConvertMailFormat(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)
{
throw
}
return stream;
}