3

Is there any way to utilize the email functionality of Send an Email button from Activities related list into a custom object? I'm trying with custom visualforce page and controller but not able to save the Email Message with my custom object.

Error:

Parent Case: Case ID: id value of incorrect type: a0A9000000QE0xtEAD Exception thrown trying to send Email Message. Details = System.DmlException: Insert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, Case ID: id value of incorrect type: a0A9000000QE0xtEAD: [ParentId]

7
  • 1
    What error you received on saving the email message on your custom object? Commented Jun 22, 2017 at 7:43
  • It shows that the Id I provided as the Parent to email message is of 18 digit and which is not correct. I also tried to truncate the last 3 digits to make it a 15 digit Id. But error is same.
    – Superman
    Commented Jun 22, 2017 at 7:45
  • are you trying custom vf just for email functionality? Commented Jun 22, 2017 at 7:46
  • 1
    If you interested in default send email functionality, I can help you with it. For visualforce error please share your error you are facing. Commented Jun 22, 2017 at 7:52
  • 1
    @LetMeCodeYou I'm more interested into the vf solution but the default functionality will be a last resort. Here is the exception Parent Case: Case ID: id value of incorrect type: a0A9000000QE0xtEAD Exception thrown trying to send Email Message. Details = System.DmlException: Insert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, Case ID: id value of incorrect type: a0A9000000QE0xtEAD: [ParentId]
    – Superman
    Commented Jun 22, 2017 at 7:58

1 Answer 1

9

As far as the default functionality concerned. All you have to do is follow the steps described below and you'll have your custom button linked with the default Salesforce email author.

  1. Create a custom button.
  2. Add the custom button on your page layout.
  3. Edit the custom button and type in a URL with your custom parameters.

Create a custom button You can create custom button by going under

setup->Create->Objects

and edit your object. Scroll down to the following section and press New Button or Link button. Give label, name and description to your button and Save.

enter image description here

Add custom button on Page Layout To add custom button on your page layout scroll to the page layouts section and Edit the page layout on which you want to add this button.

enter image description here

Then just drag & drop the button on the Custom buttons section and save the layout.

enter image description here

Edit the custom button Now this time you have to scroll to the Buttons, Links, and Actions section and edit your custom button.

![enter image description here

Once in this section here are the following things you need to focus on.

  1. URL of Email Author
  2. Parameters list

URL of Email Author Following is the base URL of email author you need to point on.

/_ui/core/email/author/EmailAuthor

If you simply put this piece of URL in front of your org's base address like this you'll get a pretty email author opened and all it is waiting is your input and the time you'll hit the Send button.

enter image description here

Apparently by your question this is all you need. But if you need to pre fill some of the information and also have an email template that you want to pull your email content from then you need to consider the following parameters list and add them into the mix. You can get the guidance from the attached screenshot of Edit button. And for your reference I'll add the complete URL at the bottom of this answer which is actually customized according to my needs and for my org.

Parameters list Below is the map of parameter name to parameter value.

p2_lkid                 To (can be Contact or Lead Id)
p3_lkid                 *Related To (usually the parent record Id)
p4                      CC
p5                      BCC
p6                      Subject
p23                     Email Body
p24                     Additional To
Template_Id             Salesforce email template Id
retURL                  *Redirection page when cancel button is clicked

Complete URL for your reference

/_ui/core/email/author/EmailAuthor?
retURL=/{!Candidate__c.Id}&
p3_lkid={!Candidate__c.Id}&
rtype=003&
p2_lkid={!Candidate__c.candidateEmail__c}&
template_id=00X90000001BB1XEAW&
p24={!Candidate__c.candidateEmail__c}

I hope it will help you and for any further questions you're welcome to ask under comments. Thanks.

1
  • 3
    Thanks for such a detailed answer. It is indeed a guide for beginners.
    – Superman
    Commented Jun 22, 2017 at 8:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .