1

Can any one help me on this ...

We are using the standard functionality of Task "Send an Email page" Send Button for the cases to reply to the customer.When the customers sends a email ,keeping in cc to service team a ticket is raised .when we click on the "Send Email Button" the cc is not getting copied . Any idea or suggestion what may be the issue.

PFA Screen Shot : enter image description here

Update - VF page constructs URL via controller as:

String redUrl = '/_ui/core/email/author/EmailAuthor?p2_lkid='+
    cas.contactId+
   '&p26='+cas.Email_to‌​_Case_Address__c +
   '&rtype=003&p3_lkid=' +cas.id + 
   '&p4='+cas.Email_CC_Address__c+
   '&p5='+ cas.Email_BCC_Address__c + 
   '&p6='+subject+ '&retURL=/'+ cas.id ;

Portion of VF PAGE :

<apex:page standardController="Case" extensions="CaseCommentAndEmailPageController">
  <apex:form >
            <apex:messages />
           <apex:pageBlock id="abc">
                <apex:pageBlockButtons location="top">
                    <apex:commandLink value="Add Comment" action="{!addComment}" rendered="{!isButtonVisible}" target="_top" styleClass="btn custBtn"/>
                    <apex:commandLink value="Send Email" action="{!sendEmail}"  rendered="{!isButtonVisible}" styleClass="btn custBtn" target="_top" />
                </apex:pageBlockButtons>

            </apex:pageBlock>
        </apex:form>
</apex:page>

Portion of Code:

   public PageReference sendEmail(){
   //old Code
        System.debug('Working.....................');
        if(cas.Email_CC_Address__c == null || cas.Email_CC_Address__c == 'null'){
             System.debug('cas.Email_CC_Address__c = '+cas.Email_CC_Address__c);
            cas.Email_CC_Address__c ='';
        }
        if(cas.Email_BCC_Address__c == null || cas.Email_BCC_Address__c == 'null'){
            System.debug('cas.Email_BCC_Address__c = '+cas.Email_BCC_Address__c);
            cas.Email_BCC_Address__c ='';
        }
        System.debug('cas.CaseNumber = '+cas.CaseNumber);
        System.debug('cas.Subject = '+cas.Subject);
        String subject = cas.CaseNumber+' - '+cas.Subject;
        if(subject.length() >= 100){
            subject = subject.subString(0,99);
            System.debug('Sub cas.Subject = '+subject);
        }
        String redUrl = '/_ui/core/email/author/EmailAuthor?p2_lkid='+cas.contactId+'&p26='+cas.Email_to_Case_Address__c +'&rtype=003&p3_lkid=' +cas.id +
                         '&p4='+cas.Email_CC_Address__c+'&p5=' + cas.Email_BCC_Address__c + '&p6='+subject+     
                        '&retURL=/'+ cas.id ;
        System.debug('redUrl = '+redUrl );
        PageReference pageRef = new PageReference('/_ui/core/email/author/EmailAuthor');
         System.debug('End.....................');
         pageRef.getParameters().put('p2_lkid',cas.contactId);
         pageRef.getParameters().put('p26',cas.Email_to_Case_Address__c);
         pageRef.getParameters().put('rtype','003');
         String caseId = cas.id;
         if(caseId != null && caseId.length() > 15){
             pageRef.getParameters().put('p3_lkid',caseId.subString(0,15));
         }
         pageRef.getParameters().put('p4',cas.Email_CC_Address__c);
         pageRef.getParameters().put('p5',cas.Email_BCC_Address__c);
         pageRef.getParameters().put('p6',subject);
         pageRef.getParameters().put('retURL',cas.id);
       // pageRef.setRedirect(true);
        return pageRef;
    }

Any help very much appreciated.

4
  • are you using emailToCase?
    – cropredy
    May 11 '16 at 13:26
  • @cropredy:Yes ,we are using email to case .We have a vf page been created and for send email button the url is given as : String redUrl = '/_ui/core/email/author/EmailAuthor?p2_lkid='+cas.contactId+'&p26='+cas.Email_to_Case_Address__c +'&rtype=003&p3_lkid=' +cas.id + '&p4='+cas.Email_CC_Address__c+'&p5=' + cas.Email_BCC_Address__c + '&p6='+subject+ '&retURL=/'+ cas.id ; but when we click on the send email button,the CC and Bcc email ids are not getting copied.Any Suggestions very much appreciated. May 11 '16 at 13:54
  • so you are not using the Send Email button on the EmailMessage related list? You have some button on the Case detail page at the Case level? Have you tried manually entering the URL via copy-paste to see if the cc is populated? Does your VF controller get email_cc_address__c in context when getRecord() is called? (It won't unless that field is in the VF markup or you use addFields() method
    – cropredy
    May 11 '16 at 16:59
  • @cropredy:The SendEmail button at case level.The above url is given at the code end and when i get a email from the customer and i reply to them by clicking the send emailbutton ...when checked in the url na32.salesforce.com/_ui/core/email/author/… ,the p4 & p5 are not getting copied .i.e cc and bcc email ids are not getting copied out.What may be the issue.Any help veyr much appreciated. May 12 '16 at 6:45
1

Sorry for the delay

This can be done without a VF controller as follows (Here I used a custom object Foo__c rather than Case as I didn't want to mess up my Dev Edition Case):

<apex:page standardController="Foo__c" extensions="FooExtensions">
    <apex:form >
        <apex:variable var="vContact" value="{!Foo__c.contact__c}"/>
        <apex:variable var="vTo" value="{!Foo__c.to__c}"/>
        <apex:variable var="vCc" value="{!Foo__c.cc__c}"/>
        <apex:variable var="vBcc" value="{!Foo__c.bcc__c}"/>
        <apex:variable var="vName" value="{!Foo__c.name}"/>
    <apex:pageMessages />
       <apex:pageBlock id="abc">
        <apex:pageBlockButtons location="top">
         <apex:commandButton value="New Comment"
            rendered="{!isButtonVisible}" styleClass="btn custBtn"
            action="{!URLFOR('00a/e',null,
                              'parent_id'=Foo__c.id,
                              'retURL'='/'+Foo__c.id)}"/>  
         <apex:commandButton value="Send Email" 
            rendered="{!isButtonVisible}" styleClass="btn custBtn"
            action="{!URLFOR('/_ui/core/email/author/EmailAuthor',$ObjectType.Task,[
                             'p2_lkid'=Foo__c.contact__c,
                             'p26'=Foo__c.to__c,
                             'rtype'='003',
                             'p3_lkid'=Foo__c.id,
                             'p4'=Foo__c.cc__c,
                             'p5'=Foo__c.bcc__c,
                             'p6'=Foo__c.name,
                             'retURL'='/'+foo__c.id                          
                                                       ])}"/>
      </apex:pageBlockButtons
    </apex:pageBlock>

    ... rest of page ...
    </apex:form>
</apex:page>

Notes

  1. The apex:variable are needed to fetch values for the various to, cc, bcc, subject, ... fields from the controller for use in the URLFOR. If your VF page already has these fields elsewhere on the page, the apex:variable is not necessary.
  2. The URLFOR creates the redirect to the new Task Send an Email page. If you are not familiar with URLFOR, its syntax can sometimes be confusing. Just like any other VF function, everything within a {!..} is either an expression of constants and/or merge fields. What is sometimes confusing is the URLFOR third parameter, labeled inputs in the VF doc without any examples (!?!). This third parameter syntax is expression=expression

If, for some reason, you have to use a Controller, then be sure that you include the <apex:variable> on your page for any field needed by the controller in your expression for redUrl.

4
  • :Thanks for your response.As suggested i tried creating the VF page .When i click on the send email button..the send an email page gets opened ,from address and Bcc address it reflects my email id and its not copying the cc field. What may be the issue.Any Suggestions very much appreciated. May 13 '16 at 10:32
  • @SalesforceCRMAccountCRM. Edit your original question with your VF page. Then I can help more.
    – cropredy
    May 13 '16 at 14:20
  • :I have updated the post VF page and controller.Any help highly appreciated. May 16 '16 at 7:00
  • I still don't see why you need a controller to do this, I amended by VF page
    – cropredy
    May 16 '16 at 17:06

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.