{"id":7405,"date":"2023-06-27T06:09:00","date_gmt":"2023-06-27T06:09:00","guid":{"rendered":"https:\/\/www.greytrix.com\/blogs\/salesforce\/?p=7405"},"modified":"2023-07-10T11:56:42","modified_gmt":"2023-07-10T11:56:42","slug":"how-to-create-an-email-as-a-quick-action-in-lightning-web-component","status":"publish","type":"post","link":"https:\/\/www.greytrix.com\/blogs\/salesforce\/2023\/06\/27\/how-to-create-an-email-as-a-quick-action-in-lightning-web-component\/","title":{"rendered":"How to Create an Email as a Quick Action in Lightning Web Component"},"content":{"rendered":"\n<p>In this blog, we will guide you on creating an Email as a Quick Action in Lightning Web Component. This Quick Action will allow you to open an Email Composer with predefined values. To achieve this, we will be using a Headless Quick Action approach. Upon loading the headless quick action, the user will be redirected to the email composer.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong><span style=\"text-decoration: underline;\"><em>Email as a Quick Action<\/em><\/span><\/strong><\/h4>\n\n\n\n<p><strong>Please refer to the following code for implementation:-<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>SendmailfromQuickActionbutton.js\nimport { LightningElement, api } from 'lwc';\nimport { NavigationMixin } from 'lightning\/navigation';\nimport { encodeDefaultFieldValues } from 'lightning\/pageReferenceUtils';\nexport default class EmailQuickAction extends NavigationMixin(LightningElement) {\n    @api recordId;\n    @api invoke() {\n        var pageRef = {\n            type: \"standard__quickAction\",\n            attributes: {\n                apiName:\"Global.SendEmail\"\n            },\n            state: {\n                recordId: this.recordId,\n                defaultFieldValues:\n                    encodeDefaultFieldValues({\n                        HtmlBody: \"Hi Sir \\n Good Morming \\n\",\n                        Subject:\"Greetings\"\n                    })\n            }\n        };\n        this&#91;NavigationMixin.Navigate](pageRef);\n    }\n}\n\nSendmailfromQuickActionbutton.js-meta.xml\n&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;LightningComponentBundle xmlns=\"http:\/\/soap.sforce.com\/2006\/04\/metadata\"&gt;\n    &lt;apiVersion&gt;56.0&lt;\/apiVersion&gt;\n    &lt;isExposed&gt;true&lt;\/isExposed&gt;\n    &lt;targets&gt;\n        &lt;target&gt;lightning__RecordAction&lt;\/target&gt;\n    &lt;\/targets&gt;\n    &lt;targetConfigs&gt;\n        &lt;targetConfig targets=\"lightning__RecordAction\"&gt;\n            &lt;actionType&gt;Action&lt;\/actionType&gt;\n        &lt;\/targetConfig&gt;\n    &lt;\/targetConfigs&gt;\n&lt;\/LightningComponentBundle&gt;\n<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\"><strong><em><span style=\"text-decoration: underline;\">Output:-<\/span><\/em><\/strong><\/h4>\n\n\n\n<center><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2023\/06\/1.Send-Email-Quick-Action.png\" target=\"_blank\" rel=\"noreferrer noopener\"><img decoding=\"async\" class=\"size-full\" style=\"border: 1px solid #A9A9A9; padding: 2px; margin: 2px; align: center;\" src=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2023\/06\/1.Send-Email-Quick-Action.png\" alt=\"Email as a Quick Action\"><\/a><\/center>\n<font size=\"2\"><center><i>Send Email Quick Action <\/i><\/center><\/font>\n\n\n\n<center><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2023\/06\/2.Email-Activity.png\" target=\"_blank\" rel=\"noreferrer noopener\"><img decoding=\"async\" class=\"size-full\" style=\"border: 1px solid #A9A9A9; padding: 2px; margin: 2px; align: center;\" src=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2023\/06\/2.Email-Activity.png\" alt=\"Email Activity\"><\/a><\/center>\n<font size=\"2\"><center><i>Email Activity <\/i><\/center><\/font>\n\n\n\n<center><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2023\/06\/3.Email-Received.png\" target=\"_blank\" rel=\"noreferrer noopener\"><img decoding=\"async\" class=\"size-full\" style=\"border: 1px solid #A9A9A9; padding: 2px; margin: 2px; align: center;\" src=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2023\/06\/3.Email-Received.png\" alt=\"Email Received\"><\/a><\/center>\n<font size=\"2\"><center><i>Email Received <\/i><\/center><\/font>\n\n\n\n<p>By following the above blog instructions, you will be able to <strong><em>\u201cCreate an Email as a Quick Action\u201c<\/em><\/strong>. If you still have queries or any related problems, don\u2019t hesitate to contact us at <a href=\"mailto:salesforce@greytrix.com\" target=\"_blank\" rel=\"noreferrer noopener\">salesforce@greytrix.com<\/a>. More details about the Product are available on <a href=\"https:\/\/www.greytrix.com\/product\/gumu\/salesforce-sage-erp-integration\" target=\"_blank\" rel=\"noreferrer noopener\">our website<\/a> and <a href=\"https:\/\/appexchange.salesforce.com\/listingDetail?listingId=a0N30000000psM5EAI\" target=\"_blank\" rel=\"noreferrer noopener\">Salesforce AppExchange<\/a>.<\/p>\n\n\n\n<p>We hope you may find this blog resourceful and helpful. However, if you still have concerns and need more help, please get in touch with us at <a href=\"mailto:salesforce@greytrix.com\" target=\"_blank\" rel=\"noreferrer noopener\">salesforce@greytrix.com<\/a>.<\/p>\n\n\n\n<p><strong><em>References<\/em><\/strong>:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"https:\/\/help.salesforce.com\/s\/articleView?id=release-notes.rn_lwc_quick_actions.htm&amp;release=232&amp;type=5\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/help.salesforce.com\/s\/articleView?id=release-notes.rn_lwc_quick_actions.htm&amp;release=232&amp;type=5<\/a><\/li><li><a href=\"https:\/\/www.salesforcebolt.com\/2023\/02\/create-email-as-quick-action-in-LWC.html\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/www.salesforcebolt.com\/2023\/02\/create-email-as-quick-action-in-LWC.html<\/a><\/li><li><a href=\"https:\/\/developer.salesforce.com\/docs\/component-library\/documentation\/en\/lwc\/use_quick_actions_email\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/developer.salesforce.com\/docs\/component-library\/documentation\/en\/lwc\/use_quick_actions_email<\/a><\/li><\/ul>\n\n\n\n<p><strong>Related Posts<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/2023\/04\/28\/how-to-upload-logo-in-salesforce-cpq-template\" target=\"_blank\" rel=\"noreferrer noopener\">How to Upload Logo in Salesforce CPQ Template<\/a><\/li><li><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/2023\/03\/31\/how-to-create-a-sandbox-template-in-salesforce\/\" target=\"_blank\" rel=\"noreferrer noopener\">How to Create a Sandbox Template in Salesforce?<\/a><\/li><li><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/2023\/03\/30\/how-to-call-screen-flow-from-lightning-web-component-in-salesforce\/\" target=\"_blank\" rel=\"noreferrer noopener\">How to call Screen Flow from Lightning Web Component in Salesforce<\/a><\/li><li><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/2022\/08\/16\/how-to-use-static-resources-in-lwc\/\" target=\"_blank\" rel=\"noreferrer noopener\">How to Use Static Resources In LWC<\/a><\/li><\/ul>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this blog, we will guide you on creating an Email as a Quick Action in Lightning Web Component. This Quick Action will allow you to open an Email Composer with predefined values. To achieve this, we will be using a Headless Quick Action approach. Upon loading the headless quick action, the user will be\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/2023\/06\/27\/how-to-create-an-email-as-a-quick-action-in-lightning-web-component\/\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[15,1450,1451,1449,367,874,392],"class_list":["post-7405","post","type-post","status-publish","format-standard","hentry","category-salesforce-srv","tag-apex-development","tag-email-as-a-quick-action","tag-email-quick-action","tag-quick-action","tag-salesforce","tag-salesforce-administrators","tag-salesforce-development"],"_links":{"self":[{"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/posts\/7405","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/comments?post=7405"}],"version-history":[{"count":3,"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/posts\/7405\/revisions"}],"predecessor-version":[{"id":7435,"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/posts\/7405\/revisions\/7435"}],"wp:attachment":[{"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/media?parent=7405"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/categories?post=7405"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/tags?post=7405"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}