I'm writing a program where user inputs and email ID and i have to send an email to that email Id. but now my requirement is that some of that text needs to be in bold. Please tell me how to do it. Thanks in advance!

  • Can you be more specific? – Artur Kępczyński Mar 5 '14 at 10:13
  • sure. its like a VF page that inputs an email Id. I use the controller for sending the email using Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage(); But in the body, i want just one word to be bold and the rest of it should be in normal font. – Sam Mar 5 '14 at 10:17
  • I strongly advice use of email template :) Because as I understand text is defined? It should be easier than adding html tags to body – Artur Kępczyński Mar 5 '14 at 10:22
  • actually the one in bold is not definite. It changes everytime a new email id is entered – Sam Mar 5 '14 at 10:57

You can use setHTMLBody() method of Email and use HTML <b></b> tags there:


        Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();                  

        String subject = 'Any Subject Line ';

        // BOLD text
        String body = 'Normal Text <b>I am Bold Text </b>; 

        // Set HTML body instead of plain text
        email.setToAddresses(new String[]{'name.surname@company.com'});

        Messaging.sendEmail(new Messaging.singleEmailMessage[] {email});

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.