Emails received have "?" sign at the beginning



in a company we are using Aspose.Email java for sending emails from our app.

Lately we have a problem with (most likely) SmtpClient and/or MailMessage classes,
basically I want to send an email which I compose from generated html (using Apose.Words), and then send it.
Problem is that while the generated HTML shows no signs of issues and basically is clean, after the email is received it contains “?” sign in the beginning right before … tag, basically this:

<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">?<html><head>

instead of

<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252"><html><head>

One thing is that we force UTF-8 charset when setting MailMessage using


But it arrives with Windows-1252.

I’ve debugged the code and on each line where the email body is set or somehow manipulated I never seen “?”, and because I cannot debug (obviously) the Aspose classes I assume the issue is somewhere inside them.

public void sendMessage(EmailMessage message) throws DAFException {
SmtpClient client = new SmtpClient();

  try {
  } catch (Exception fail) {
  try {
  	MailMessage content = new MailMessage();

  	if (getGridProperties().isEmailFromAllowOverride() && message.getFrom() != null && message.getFrom().contains("@")) {
  		content.setFrom(getMailAddress(message.getFrom(), message.getFromName()));
  	} else {
  		content.setFrom(getMailAddress(getGridProperties().getEmailFromAddress(), getGridProperties().getEmailFromDisplayName()));
  			new MailAddressCollection() {{
  	content.setSubject(message.getSubject().replaceAll("\\<.*?>", ""));
  	content.setBody(message.getBody().replaceAll("\\<.*?>", ""));


  } catch (Exception fail) {
  } finally {
  	if (client != null) {


I’ve removed some code unrealted to code manipulation like loggers, validation checks and such and replaced constants with magic Strings
the getGridProperties() call is just to get proper data from our application server.

I forgot about important thing, I’ve also tested adding the HTML directly instead of it being generated and the “?” wa still there when email was received.



I have observed the issue shared by you and request you to please first try using latest Aspose.Email for Java 19.7 on your end. In case the issue still persist then share the working sample example along with source file (if any) reproducing the issue on your end that we may try to reproduce on our end.


Thank you for your response, I’ve tested it with Aspose.Email 19.7 but the issue is still there.

Can you tell me what exactly do you need for your investigation? I’ve posted the code we are using in my original post so perhaps something else?



Can you please source email file which you used on your end so that we may further investigate to help you out.

#5 (1.6 MB)

I’ve added .zip file with one .txt and one .html files, these represent the data we use in
MailMessage content = new MailMessage(); where content is content.setHtmlBody(message.getHtmlBody());

the “message” is just POJO, getHtmlBody() returns String, however the String is exactly what I send in those two files, no ‘?’ added to it anywhere in method until
client.send(content); where client is SmtpClient client = new SmtpClient();
which I obviously cannot debug.

I’ve also attached email as it arrives already with broken html.
We use Aspose.Words for file conversion/s but this seems to not cause the problem as the html I’ve sent is being generated before the POJO/ htmlBody field even receives it and is correct.



I have worked with sample code shared by you. Can you please share complete working sample project. The code snippet you have shared includes some undeclared variables so would you please share SSCCE code reproducing the issue so that we may try to reproduce and investigate it in our environment.


Here is pastebin with code

I’ve noticed one thing tho, there is deprecated method in SmtpClient - setEncoding(),
when I use this like this: .setEncoding(java.nio.charset.StandardCharsets.UTF_8);
and together with the HTML hardcoded the “?” is not showing anymore.

But it still shows the “?” when I just parse generated HTML (identical to one I sent before or the one in the pasteBin code) using getter method from EmailMessage class which returns String and nothing else…



I have worked with your sample code for further investigation can you please share temporarily the test account credentials so that we may help you out.


Unfortunately I cannot give you our test email server credentials, not only it is accessible only with VPN but I am also not allowed to share them.



I can understand the limitation on your end. We have created an issue with ID EMAILJAVA-34573 as investigation on our end to possibly reproduce and resolve the issue on our end. This thread has been linked with the issue so that you may be notified once the issue will be fixed.