3

So I have the following class:

public static void sendmail(String documenttitle)
{
    List<Id> contactids = new List<Id>();
    List<user> con = new List<User>();
    con = [select Id from User where name IN ('User A', 'User B', 'User C', 'User D')];
    for(User u : con)
    {
        contactids.add(u.Id);
    }  


ContentDocument cont = new ContentDocument();


if(documenttitle.contains('Media'))
{
    Messaging.MassEmailMessage mail = new Messaging.MassEmailMessage();
    mail.setTargetObjectIds(contactids);
    mail.setTemplateId('00AA0000001AaaA');
    mail.saveAsActivity = false;
    Messaging.sendEmail(new Messaging.MassEmailMessage[] { mail });
} 

}

Which sends out an email to four recipients (Users A-D) when apiece of content with the word "Media" in the title is uploaded.

Now, Is there a way to include things such as:

ContentVersion.Title();
ContentVersion.Description();
ContentVersion.ContentUrl();
ContentVersion.OWnerID();

etc...

into the body of the email through apex? I can't seem to find a way to access that info directly through the email template...

0

You should be able to do a SOQL query and a Visualforce email template.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.