MapiMessage.setBodyContent(htmlBody,BodyContentType.Html); styles not visible for html content

I am trying to send mail using GraphClient by adding Html content as body content. I have added table in the content but table border is not visible and data for tag is not displayed as bold. I am using below code please help me @sergey.vivsiuk

Code :

String htmlBody = “

Mailbox Folder Name Number of email in folder Comment
Kumar123@gmail.com Processing 10 Processing Mails
”;
IGraphClient client = getAuoth();
client.setResource(ResourceType.Users);
client.setResourceId(“test12356@gmail.com);
//Create message object and set properties
MapiMessage message = new MapiMessage();
message.setProperty(KnownPropertyList.DISPLAY_TO, “test123@gmail.com”);
message.setBodyContent(htmlBody,BodyContentType.Html);
message.setSubject(” Email Processing");
// Send message
client.send(message);

Output : Getting below output without table border and table header row is not in bold.

Mailbox Folder Name Number of email in folder Comment
Kumar123@gmail.com Processing 10 Processing Mails

Hello @jashuvaprasannakumar.kotte,

Your issue is taken for investigation. We’ll contact you as soon as we have results.

Thanks for reporting your case.

@jashuvaprasannakumar.kotte,

I have tested the issue with our test account.
The Message is displayed correctly in Outlook.
1.png (10.1 KB)

Could you share more info on how to reproduce the issue?

Hi @sergey.vivsiuk

Please refer below screenshots of my code which includes html and mail screenshot. Please let me know if any changes required in HTML code or GraphClient code

GraphMail.png (2.7 KB)

GraphMail.PNG (15.7 KB)

@jashuvaprasannakumar.kotte,

Thanks for the additional info.

@jashuvaprasannakumar.kotte,

Could you check the HTML code?
Opening and ending tag mismatch: td and th

...
<td>10</th>
...

Hi Sergey,

Issue still exists HTML code is correct, Before sending mail I am saving the email to local disc there table border and confidentiality are visible. But after sending table border and confidentiality are not visible if I check in receiver’s mail inbox. What could be the issue, please help me. Please refer the below screenshots.

Local Disc Mail.PNG (27.1 KB)Mail From Inbox.PNG (7.0 KB)

Hello @jashuvaprasannakumar.kotte,

Your issue is taken for investigation. We’ll contact you as soon as we have results.

Thanks for reporting your case.

I will be waiting for your reply.

I have tested the issue with our MSGraph test account and issue was not reproduced.

Test code:

String htmlBody = "<html><body><table border=1><tr><th><b>Mailbox<b></th><th>Folder Name</th><th>Number of email in folder</th><th>Comment</th></tr><tr><td>Kumar123@gmail.com</td><td>Processing</td><td>10</td><td>Processing Mails</td></tr></table></body></html>";
//Create message object and set properties
MapiMessage message = new MapiMessage();
message.setProperty(KnownPropertyList.DISPLAY_TO, "test1@xxonmicrosoft.com");
message.setBodyContent(htmlBody,BodyContentType.Html);
message.setSubject("Email Processing");

// Send message
final IGraphClient client = TestUtil.createGraphClient(user);
client.send(message);

Mail From Inbox:
0.png (4.9 KB)

Could you please share with us more information on how to reproduce the issue?

Hi Sergey,

The main thing here is setting Sensitivity, even that is not getting applied. Could you please check this also.

message.setSensitivity(MapiSensitivity.CompanyConfidential);

@jashuvaprasannakumar.kotte,

I have tested the issue with setSensitivity, the same result, the issue is not reproduced.

...
message.setBodyContent(htmlBody,BodyContentType.Html);
message.setSubject("Email Processing");
message.setSensitivity(MapiSensitivity.CompanyConfidential);
..
client.send(message);

Hi @sergey.vivsiuk,

Is that possible to have a meeting, so that I can show you issue.

Hello @jashuvaprasannakumar.kotte,

Unfortunately, there’s no such a possibility to solve issues via meetings.

Please try to clarify the issue here.

Hi Margarita,

Below is my code
1). I am trying to set mail sensitivity for the mail being sent, but sensitivity is not getting applied to the mail received.
2).And I am trying to send some html code with table in the body content, but table is not getting displayed, I tried including many styles in html code but nothing is not getting displayed in the received mail.

 String htmlBody = "<html><body><table border=1><tr><th><b>Mailbox<b></th><th>Folder Name</th><th>Number of email in folder</th><th>Comment</th></tr><tr><td>Kumar123@gmail.com</td><td>Processing</td><td>10</td><td>Processing Mails</td></tr></table></body></html>";
             final IGraphClient client = getAuoth();
	client.setResource(ResourceType.Users);
	client.setResourceId("test_123@kbca.com");
	
	 InputStream inputStream = null;
	 com.aspose.email.License licenseE = new com.aspose.email.License();
	 inputStream = this.getClass().getResourceAsStream("/Aspose.Total.Java.lic");
     licenseE.setLicense(inputStream);	
	 
	MapiMessage message = new MapiMessage();
	message.setProperty(KnownPropertyList.DISPLAY_TO, "test349@gmail.com");    	    	
	message.setBodyContent(htmlBody,BodyContentType.Html);		
	message.setSubject("Email Processing Report");
	message.setSensitivity(MapiSensitivity.CompanyConfidential);		
	message.save("C:\\Users\\Test\\GraphClient\\Mails\\"+message.getSubject()+".msg");    	
	client.send(message);

I am using below maven dependency. --> version : 22.3

I am attaching the screenshot of the mail received that is being sent from the above code. Please help me in this. You can refer to above conversation for more details.

Mail From Inbox.PNG (7.0 KB)

Hello @jashuvaprasannakumar.kotte,

Thank you for the clarification. Our developers will investigate your case asap.

Hello @jashuvaprasannakumar.kotte,

The issue has been fixed in the Aspose.Email for Java 22.6 release.

Hi @sergey.vivsiuk,

HTML code parsing issue got fixed with Java 22.6 release, thanks for the solution, but mail sensitivity is not getting applied to the mail received. What will be the solution for this issue. Please help me in this issue.

Mail_Sensitivity.PNG (4.1 KB)

@jashuvaprasannakumar.kotte,

Could you check the sensitivity issue with the sendAsMime Graph API method released in Aspose.Email for Java 23.6.
(pay attention to adding the recipient to the message getRecipients().add(…)

MapiMessage message = new MapiMessage();
message.getRecipients().add("test349", "test349@gmail.com", MapiRecipientType.MAPI_TO);
//message.setProperty(KnownPropertyList.DISPLAY_TO, "test349@gmail.com");
message.setBodyContent(htmlBody,BodyContentType.Html);
message.setSubject("Email Processing Report");
message.setSensitivity(MapiSensitivity.CompanyConfidential);
// Send As Mime
client.sendAsMime(message);

Hi @sergey.vivsiuk,

Thank you so much that worked.