You need to sign in to do that
Don't have an account?
kris chit
Email notification on ContentVersion object
Hi,
I am sending an email notification if a field is changed on Content Version object through Apex as we cannot create Workflows/processbuilder on Contentversion object. In my Apex code, I am referring to a email template which I created for this purpose. In the body of email I am trying to include few ContentVersion fields, but there is no option to select merge fields for Content Version object.
Is there a way I can use ContentVersion fields in my email template ?
I am sending an email notification if a field is changed on Content Version object through Apex as we cannot create Workflows/processbuilder on Contentversion object. In my Apex code, I am referring to a email template which I created for this purpose. In the body of email I am trying to include few ContentVersion fields, but there is no option to select merge fields for Content Version object.
Is there a way I can use ContentVersion fields in my email template ?
You can't just use the fields of content Version ,But you can query the contentversion and include into email as attachment,see the code below:
1.If you have the ContentDocument Id you can fetch the ContentVersion file as this:
// If you only want the ContentVersion ID's
or you can mix both code, I just picked part of mine as example but do everything in one SOQL query
You can attach those Messaging.EmailFileAttachment with public Void setFileAttachments(EmailFileAttachment[] fileNames) Or only the Ids with public void setEntityAttachments(List<String> ids).
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks and Regards,
Deepali Kulshrestha
www.kdeepali.com
How to write test class you have provided over here to cover the for loop in the code?
Please follow below sample code:-
TestClass:-
if you need any assistanse, Please let me know!!
Kindly mark my solution as the best answer if it helps you.
Thanks
Mukesh