How can I display email body in bold letters
Hello,
I am writing a plugin for work item save operation which is responsible for sending email to owner of task if certain conditions are met. I have successfully written plugin and tested it on my jetty plugin test environment setup. I am using below method to send email
IMailerService mailService = getService(IMailerService.class);
mailService.sendMail(mailService.getDefaultSender(), mailAddress, emailSubject, emailBody, "");
"emailBody" is string variable, content of emailBody variable are displayed in mail body when user receives email.
Our users have demanded to make certain part of mail body in bold letters, I have been looking searching on how can I make content of string appear as bold letter in email body, one of the approach was
String emailBody = "<b> this is mail body </b>"
But instead of displaying text in bold letters (like this - this is mail body) it is displaying entire text (i.e. <b> this is mail body) in plain letters.
Is there any way we can make content of email body in bold format?
|
3 answers
Ralph Schoon (63.5k●3●36●46)
| answered Aug 13 '18, 3:19 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER This seems to be a client problem and not a server or API problem. The client interprets the mail as a string and not as an HTML.
|
David Lafreniere (4.8k●7)
| answered Aug 28 '18, 12:34 a.m.
FORUM MODERATOR / JAZZ DEVELOPER edited Sep 06 '18, 9:11 a.m.
You are using the wrong API.
You need to create a MimeBodyPart and set the Content-type = text/html header, and then use the API that accepts a MimeMultipart.
See the following code:
IMailerService mailservice = getMailerService();
MimeBodyPart plainBody= new MimeBodyPart();
plainBody.setText(getPlainContent(), UTF_8); MimeBodyPart htmlBody= new MimeBodyPart(); htmlBody.setText(getHtmlContent(), UTF_8); htmlBody.setHeader("Content-type", "text/html; charset=" + UTF_8); //$NON-NLS-1$ //$NON-NLS-2$ MimeMultipart multipart= new MimeMultipart("alternative"); //$NON-NLS-1$ multipart.addBodyPart(plainBody); multipart.addBodyPart(htmlBody); mailer.sendMultipartMail(mailservice .getDefaultSender(), getEmailAddress(), "My email subject", multipart, null); Comments
Hi David
I have tried your above mentions scenario but i am getting
Unable to save work item.javax.mail.BodyPart. error on save work item
Can you provide more of the stack trace, there's not enough information there to tell what's going wrong.
|
MimeBodyPart plainBody = new MimeBodyPart();
}
I wrote this code but its giving me error as mentioned above
please correct me
Comments
Rohini Kumar
commented Sep 06 '18, 6:41 a.m.
please give me a suggestions on same
We're still going to need the exception stack trace.
Rohini Kumar
commented Sep 07 '18, 8:43 a.m.
hi David I am unable o get stack trace data, I am stuck in to send html mail,can you please provide sample example related to it
The code provided in my comment was the sample example, I do not know what other code to provide other than that. Hopefully some other readers might be able to help out here.
Why can't you get the stack trace? It should be either in the server log or client log somewhere. Are you able to debug the issue to see what's happening?
Also, is that really the title that is given for the error? It's not even a grammatically correct sentence so I'm not sure how to understand it: "Unable to save work item.javax.mail.BodyPart"
Rohini Kumar
commented Sep 08 '18, 7:27 a.m.
hi Devid, When I add above mentioned cod then I unable to debug the code ,I am unable to trigger code
Did you remember to add the appropriate imports?
Rohini Kumar
commented Sep 11 '18, 2:36 a.m.
Thank you Devid for quick response, now code is working fine.
showing 5 of 7
show 2 more comments
|
Your answer
Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.