function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Bharat Chandra MohantyBharat Chandra Mohanty 

how to attach files from notes and attachment to email composer

Hi 
I have invoked the standard email composer in lwc ,I am passing to address,body,subject in js.

But i want to add a attachment which is there in notes and attachment.
The referrence Email composer (https://developer.salesforce.com/docs/component-library/documentation/en/lwc/use_quick_actions_email)

How to pass the contentDocumentId in js 

Thanks in advance
 

Benjamin LetellierBenjamin Letellier

Hello, I'm facing the exact same issue, and I cannot really find any further documentation on how to use this standard LWC email composer.
So I'm just fumbling in the dark, experimenting. I noticed in the example given on the link you shared, the two fields 'htmlBody' and 'subject' seem to be the ones found on the EmailMessage Object (https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_emailmessage.htm).

So I tried adding the 'ToIds' field for instance, which is a JunctionIdList, and provided a Contact Id for it, and it works: the email composer does open with the said contact prepopulated.

Then I tried populating the field of interest for us: 'ContentDocumentIds', which is also a JunctionIdList field on the EmailMessage Object, but I get an uncaught exception in javascript...

gD {component: 'support:sendEmailQuickAction$controller$init', componentStack: '[runtime_platform_actions:quickActionWrapper] > [s…rQuickSendEmail] > [support:sendEmailQuickAction]', action: null, name: 'TypeError', message: 'Action failed: support:sendEmailQuickAction$contro…init [b.ContentDocumentIds.map is not a function]'
Here's the code, ToIds on its own works fine, but adding ContentDocumentIds results in the exception above:
let pageRef = {
			type: "standard__quickAction",
			attributes: {
				apiName: "Global.SendEmail"
			},
			state: {
				recordId: this.recordId,
				defaultFieldValues: encodeDefaultFieldValues({
					HtmlBody: "Default values from Quick Action.",
					Subject: "Only trying to attach a File to an email in SF...",
					ToIds: "0037Q00000DzHSCQA3",
					ContentDocumentIds: "0697Q000007byHAQAY"
				})
			}
		};
		this[NavigationMixin.Navigate](pageRef);
If anyone has some knowledge on that, I'm also interested :)
Kyle O'Brien 16Kyle O'Brien 16
I am facing the same issue as Benjamin, I have an email quick action that is working as expected without the "ContentDocumentIds" field, but I get a similar error when I try adding this field:
message: "Action failed: support:sendEmailQuickAction$controller$init [fieldOverrides.ContentDocumentIds.map is not a function]"
name: "TypeError"
stacktraceIdGen: Component init failed"
stacktraceIdGenModifier: "Component init failed"
stack: "TypeError: fieldOverrides.ContentDocumentIds.map is not a function\n
 
var pageRef = {
                type: "standard__quickAction",
                attributes: {
                    apiName: isCase ? "Case." + this.emailGlobalActionsName : "Global." + this.emailGlobalActionsName
                },
                state: {
                    recordId: this.recordId,
                    defaultFieldValues: encodeDefaultFieldValues({
                        ContentDocumentIds: "06905000003TF1cAAG",
                        HtmlBody: this._htmlBody ? this._htmlBody : this._itemLinks,
                        Subject: this._subject,
                        ToIds: this._toIds ? this._toIds.join(",") : null
                    })
                }
            };
            resolve(this[NavigationMixin.Navigate](pageRef));

Any knowledge on how to attach files would be greatly appreciated