emailpublisher

Using apex:emailPublisher in Salesforce

This post is about, how to use apex:emailPublisher for our Support personals. They can send emails from the Case Feed without having to leave the workspace. So here we are with Using apex:emailPublisher in Salesforce. This can be only used in organizations where we have Case Feed and Email-to-Case are enabled. If you have not enabled it yet, you can enable it and try the steps below:

Using apex:emailPublisher in Salesforce

Step 1: Enable the Case Feed and Email-to-Case. for that search for email-to-case in quick find in setup and follow the steps to enable it:

email-to-case settings
email-to-case settings

If you have not enabled yet and try to create the below code, you will get error saying the emailPublilsher component does not exists. Just enable this and you should be good to save this code.

Step 2:
Create a visualforce page, with below code:

<apex:page standardController=”Case” showHeader=”false” sidebar=”false” setup=”false”>
<apex:emailPublisher id=”ktpulisher”
entityId=”{!case.id}”
width=”500px”
sendButtonName=”GettheKT”
title=”GettheKT Email Form”
expandableHeader=”false”
autoCollapseBody=”false”
showAdditionalFields=”false”
enableQuickText=”true”
fromVisibility=”selectable”
toVisibility=”editable”
bccVisibility=”hidden”
ccVisibility=”hidden”
emailBody=””
subject=”GetTheKt Email: ”
toAddresses=””
onSubmitFailure=”alert(‘Ther is some error. Please try again later!’);”
fromAddresses=”info@getthekt.com”
/>
</apex:page>

Step 3: Create a Case Action as below, using the VF page we just created:


Step 4: Add the Action to the Case Feed page by going in to the edit pagelayout:

Step 5: If you see the below error message, create a permission set and assign it to the users, who will be using this Publisher Action:

  1. Create a permission set for Case Feed.
  2. On the Permission Set page, click App Permissions.
  3. Select Use Case Feed.
  4. Click Save.

“This component is only available on Case Feed page layouts.”

Step 6: Testing time 🙂 Go the the case page and select any case to see the newly created publisher action. There are a lot of ways you can brand it like your own.

 

 

 

Attributes

Attribute Name Attribute Type Description Required? API Version Access
autoCollapseBody Boolean A Boolean value that specifies whether the email body will be collapsed to a small height when it is empty. 25.0
bccVisibility String The visibility of the BCC field can be ‘editable’, ‘editableWithLookup’, ‘readOnly’, or ‘hidden’. 25.0
ccVisibility String The visibility of the CC field can be ‘editable’, ‘editableWithLookup’, ‘readOnly’, or ‘hidden’. 25.0
emailBody String The default text value of the email body. 25.0
emailBodyFormat String The format of the email body can be ‘text’, ‘HTML’, or ‘textAndHTML’. 25.0
emailBodyHeight String The height of the email body in em. 25.0
enableQuickText Boolean If the quick text autocomplete functionality will be available in the publisher. 25.0
entityId id Entity ID of the record for which to display the email publisher. In the current version only Case record ids are supported. Yes 25.0
expandableHeader Boolean A Boolean value that specifies whether the header is expandable or fixed. 25.0
fromAddresses String A restricted set of from addresses. 25.0
fromVisibility String The visibility of the From field can be ‘selectable’ or ‘hidden’. 25.0
id String An identifier that allows the component to be referenced by other components in the page. 14.0 global
onSubmitFailure String The JavaScript invoked if the email failed to be sent. 25.0
onSubmitSuccess String The JavaScript invoked if the email was successfully sent. 25.0
rendered Boolean A Boolean value that specifies whether the component is rendered on the page. If not specified, this value defaults to true. 14.0 global
reRender Object The ID of one or more components that are redrawn when the email was successfully sent. This value can be a single ID, a comma-separated list of IDs, or a merge field expression for a list or collection of IDs. 25.0
sendButtonName String The name of the send button in the email publisher. 25.0
showAdditionalFields Boolean A Boolean value that specifies whether the additional fields defined in the publisher layout should be displayed. 25.0
showAttachments Boolean A Boolean value that specifies whether the attachment selector should be displayed. 25.0
showSendButton Boolean A Boolean value that specifies whether the send button should be displayed. 25.0
showTemplates Boolean A Boolean value that specifies whether the template selector should be displayed. 25.0
subject String The default value of the Subject. 25.0
subjectVisibility String The visibility of the Subject field can be ‘editable’, ‘readOnly’, or ‘hidden’. 25.0
submitFunctionName String The name of a function that can be called from JavaScript to send the email. 25.0
title String The title displayed in the email publisher header. 25.0
toAddresses String The default value of the To field. 25.0
toVisibility String The visibility of the To field can be ‘editable’, ‘editableWithLookup’, ‘readOnly’, or ‘hidden’. 25.0
verticalResize Boolean A Boolean value that specifies whether the publisher allows vertical resizing. 30.0
width String The width of the email publisher in pixels (px) or percentage (%). 25.0

 

Conclusion:

Here comes the end of the post for now. Having trouble in any step ? You can always reach out for help 🙂 Love to hear your thoughts on these posts. Thanks for reading and sharing…

Keep reading and sharing….


Comments

10 responses to “Using apex:emailPublisher in Salesforce”

  1. mounisha Avatar

    Hi,

    I am getting the error you have mentioned in Step 5. But when I am trying to create Permission set -I am no able to see “Use Case Feed” option to enable.

    Can you help me with that. It would help me alot.
    Thanks In Advance!

    1. Hi, Thanks for reaching out. As of Spring ’14 release when they added feed-based layouts to the case feeds From what I have seen if you have turned on Case Feeds prior to Spring ’14 you will have the Case Feed layoutss, however if you turn it on after the Spring ’14 release you will not have that permission as it defaults to which ever layout you have assigned to the profile, for the feed view you need a feed-based layout and for the detail view only you will have a non feed-based layout.

      1. Mounisha Avatar

        Hi, Thanks for the quick response.

        It’s working fine in my Developer environment. But I was trying to implement the same in Sandbox, I am getting below error for system Admin.
        “send email is not available for current user. Please verify your setup.”

        I tried enabling all the settings. Can you help me out with this.

        Sorry for troubling you. Thanks in advance!

        1. Have you already checked the email delivery settings in the sandbox ?

          Setup > Email > Deliverability > Access Level “All Eamils”

  2. May be the Case Feed had not yet been enabled. Have you checked that as well ?

    1. mounisha Avatar

      Yes, I have Email deliverability and Case Feed as well.

      The error was not in front end. I tried to inspect the screen, where I found this “

  3. mounisha Avatar

    Yes, I have Email deliverability and Case Feed as well.

    The error was not in front end. I tried to inspect the screen, where I found this “

  4. Thanks for the awesome post. I am trying to figure out where to configure the fields to show when I set showAdditionalFields=”true on apex:emailPublisher tag.

    1. Amit Sahu Avatar

      The fields will be configured on the layout

Leave a Reply

Your email address will not be published. Required fields are marked *