Free Support Forum - aspose.com

Pst eml msg

hi All,

i have one pst file, it contains an eml file. I use email liblary you provide to parse pst and get content.

save content as eml. then convert it msg. save the msg to a new pst.

but finllay the original eml as attachemnt of new msg. and the attachemnt format is msg.

how can i fix this issue?

thanks,
Nicq

@nicq.chen,

Thank you for writing to Aspose Support team.

You need to use Preserve embedded EML format while converting to MSG format. Please have a look at the following code sample for your kind reference. If the issue still persists, please share your sample PST file and code with us for further investigation at our end.

Sample Code

string dataDir = RunExamples.GetDataDir_Email();

var eml = MailMessage.Load(dataDir + "sample.eml", new EmlLoadOptions());

var options = MapiConversionOptions.UnicodeFormat;

//Preserve Embedded Message Format
options.PreserveEmbeddedMessageFormat = true;

//Convert EML to MSG with Options
var msg = MapiMessage.FromMailMessage(eml, options);

thanks, it worked.

@nicq.chen,

You are welcome.

I got one more issue, there is msg file as attachment in eml, and eml in pst file.
I used mehtod you shared. the msg attachment can’t open any more. could you help on this.

                    EmlLoadOptions emlLoadOptions = new EmlLoadOptions();
                    emlLoadOptions.setPreserveEmbeddedMessageFormat(true);
                    emlLoadOptions.setPreserveTnefAttachments(true);
                    MailMessage eml = MailMessage.load(new ByteArrayInputStream(attachment.getBinaryData()), emlLoadOptions);

                    MapiConversionOptions opts = MapiConversionOptions.getUnicodeFormat();
                    opts.setPreserveEmbeddedMessageFormat(true);
                    opts.setUseBodyCompression(false);
                    opts.setPreserveSignature(true);

                    MapiMessage msg = MapiMessage.fromMailMessage(eml, opts);
                    targetFolder.addMessage(msg);

@nicq.chen,

Please share your sample PST file with us for further investigation at our end. We’ll look into it for assisting you further.

thans for you quick response, i have fix this issue. with code as below.

MailMessage eml = MailMessage.load(new ByteArrayInputStream(attachment.getBinaryData()), new EmlLoadOptions());

                    MapiConversionOptions options = new MapiConversionOptions();
                    options.setPreserveOriginalAddresses(false);
                    MapiMessage msg = MapiMessage.fromMailMessage(eml, options);
                    targetFolder.addMessage(msg);
                    eml.dispose();
                    msg.dispose();

but there is another issue. for mail address from.
it will not show original ones.

MicrosoftExchange329e71ec88ae4615bbc36ab6ce41109e@exchange.standardchartered.com; on behalf of Wang

lt like above.

@nicq.chen,

The PreserveOriginalAddresses method had been introduced to preserve special characters in the email address. The above address format you have shared is Exchange Server format and is part of email addresses in some cases. We need your sample input file for further looking into this behaviour of the API. As requested earlier, please share your sample PST file with us along with the code sample you are trying at your end and the expected behaviour. This will help us investigate the issue for assisting you further.

hi kashif,

Any feedback?

@nicq.chen,

Please share your sample EML file in its original form as well that we can use with your code sample for investigating the issue further at our end.

https://github.com/nicqchen01/Algo/blob/master/test.pst

plesae check this file

@nicq.chen,

Thank you for providing the sample data. This issue is re-produced and logged under Id: EMAILJAVA-34304 for further investigation by the product team. You will be automatically notified once any update is received in this regard.

hi,

could you know when i can get updated relesae version? because I am pending on this issue and make purchase contract.

@nicq.chen,

The fix version will be available for download in the last week of Sep 2017. We’ll notify you here once the fix version is available for download.

@nicq.chen,

This issue has been fixed in the latest release of Aspose.Email for .NET 17.9. Please let us know if we can be of any additional help to you in this regard.

thanks, actually i am using java version, when can i get it ?

one more question is about when the source pst file include more than 1000 mails. after i convert it to

pst that include msg files. It will empty when i open it with outlook. is there any limitation for trail version?

@nicq.chen,

Aspose.Email for Java 17.9 is available for download now.

There is no such limitations as 1000 mails on PST file. The only evaluation limitations are as mentioned in the API documentation. Please share your sample PST file with us along with the code sample for further investigation at our end.

thanks, let me try it.

 If the full license version has any limitation on the number of emails that can be extracted from a PST file or is it unlimited?
      Is there any limitation of the size of the PST file that can be processed?
      If there is any limitation in the number of attachments in the email that can be extracted in the full license version?

@nicq.chen,

As mentioned in the evaluation limitations section of the article, the only limitations on working with PST files is that only 50 emails can be extracted. If your problem still persists, please create a new topic along with your sample PST file and sample code for further investigation at our end. We’ll look into it for assisting you further.