Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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)

ContentDocument cont = new ContentDocument();

    Messaging.MassEmailMessage mail = new Messaging.MassEmailMessage();
    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:



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...

share|improve this question
up vote 0 down vote accepted

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

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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