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

Free Support Forum - aspose.com

StringIndexOutOfBoundException

Hello

If MapiMessage.setBodyContent() is invoked with params

("I&#39;m<br>You&#39;re<br>He&#39;s<br>She&#39;s<br>I&#39;ll<br>We&#39;ve<br>!@#$%^&*()?&quot;:><", BodyContentType.HTML)

It fails with exception

java.lang.StringIndexOutOfBoundsException: String index out of range: 1
        at java.lang.String.charAt(String.java:658)
        at com.aspose.email.yh.a(SourceFile:519)
        at com.aspose.email.yh.a(SourceFile:398)
        at com.aspose.email.yh.a(SourceFile:263)
        at com.aspose.email.azo.g(SourceFile:326)
        at com.aspose.email.MapiMessageItemBase.setBodyContent(SourceFile:1368)

@Zeruch,

We were able to generate the exception using the code that you provided. The exception disappears if we remove the last opening angle bracket or surround the string with HTML tags as shown below.

"I&#39;m<br>You&#39;re<br>He&#39;s<br>She&#39;s<br>I&#39;ll<br>We&#39;ve<br>!@#$%^&*()?&quot;:>"

or

"<p>I&#39;m<br>You&#39;re<br>He&#39;s<br>She&#39;s<br>I&#39;ll<br>We&#39;ve<br>!@#$%^&*()?&quot;:><</p>"

We hope that this answered your question. Please feel free to reach us if additional information is required.

Hi @muhammadahmad
Thanks for your reply.

Such behavior looks strange to me as this string is properly displayed in an html document, opened in browser. Therefore, it’s expected that this string would be displayed in Outlook mail as well (or at least converted without exceptions).

@Zeruch,

Thank you for your feedback. We have logged an investigation in our issue tracking system as EMAILJAVA-34448 to investigate this further. We will update you as soon as additional information is available.

The issues you have found earlier (filed as EMAILJAVA-34448) have been fixed in this update. This message was posted using BugNotificationTool from Downloads module by MuzammilKhan