We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

PST - java HeaderCollection.set(name, value) method fails when cyrillic symbols are provided


I’ve tried creating a PST file and it failed when I was trying to set MapiMessage headers via HeaderCollection.set("name", "тест") with an exception
class com.aspose.email.system.exceptions.FormatException: An invalid character was found in header value.

I’ve dived into code and it looks like only ASCII characters can be provided or am I missing something? If so, why is it implemented that way?


You may use the code sample given below:

mesage.getHeaders().add("secret-header", "mystery");

Moreover, please find more details at this link:

Thanks for your reply

I’ve tried using HeaderCollection.add("name", "тест"), it worked without an exception, but later the header value is displayed as base64-encoded string =?windows-1251?B?8uXx8g==?= and not as original value тест.
This base64 string is also displayed when I import the .pst file to MS Outlook.

Is there any workaround?

Ok, I’ve managed to resolve this.
I had to use HeaderCollection.add_("name", "тест"), which then displayed the header correctly.

I think this should be fixed somehow or at least documented, cos it’s really confusing.

Thanks, the thread may be closed.


Thank you for your feedback.
We look into it and update the documentation. However, you may suggest to improve the solution. Your valuable suggestions are always welcome.