0

I am prepopulating the email bod as shown in the highlighted line. When the email is sent, the receiver sees the lines appended to the email body. However the sender when drafting the email doesn't see the text or link appended to the body. Is there a way to prepoulate the email body so that the sender too sees the appended text before sending the email.

Thanks.!!


public PageReference sendEmail(){

        tId = ApexPages.currentPage().getParameters().get('Id');

        String emailimageid = mytm.Email_Image_Id__c;

        tComment = new MY_Comments__c();
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();

        if(emailTo != null && emailTo.trim() != ''){
        toaddress = emailTo.split(',',0);
                if(toaddress.size()>0){
                mail.setToAddresses(toaddress);
                }
        }

        if(emailCC != null && emailCC.trim() != ''){
        ccaddress = emailCC.split(',',0);
                if(ccaddress.size()>0){
                mail.setCcAddresses(ccaddress);
                }
        }
        mail.setSubject(emailSubject);
**mail.setHTMLBody(emailBody +  '
' + '
' + '\n Click the link below' + '
' + ' \n https://na9.salesforce.com/' +MYtransactionId + '
' + '
' + '' +' \n DEADLINE: A RESPONSE MUST BE INITIATED IN SALESFORCE WITHIN 48 HOURS OF RECEIPT OF THIS MESSAGE');** try{ Messaging.SendEmailResult[] resultMail = Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail }); if(resultMail[0].isSuccess()) { } catch{ }

1 Answer 1

2

Assuming emailBody is set from something like a apex:inputField.

<apex:inputText value="{!emailBody}" id="emailBody "/>

Have you tried simply setting emailBody to the "appended text" when you load the page? In the controller constructor would work fine.

public constructor(){
    emailBody = '\n Click the link below' + '
                ' + ' \n https://na9.salesforce.com/' +MYtransactionId +  '' + '
                ' + '' +' \n DEADLINE: A RESPONSE MUST BE INITIATED IN SALESFORCE WITHIN 48 HOURS OF RECEIPT OF THIS MESSAGE'
}

To pre-populate the inputField with that text then modify it? Then just use:

mail.setHTMLBody(emailBody)
0

You must log in to answer this question.