I'm trying to create a button which will pull emails from a list view and push them to an empty email template. It is for a custom object (Students_Programs__c) which has a custom formula field for emails (Email__c) which pulls the email from the contact associated with the record.
The problem I have run into so far is that it gets to the blank email template but populates emails as "undefined". I haven't been able to figure out why it is doing this which is unsurprising as I know next to nothing about javascript and have really just been hacking up and splicing code I have found through online searching.
Here's what I have though.
{!REQUIRESCRIPT("/soap/ajax/25.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/25.0/apex.js")}
var emailAddresses = '';
var records = {!GETRECORDIDS($ObjectType.Students_Programs__c)};
if (records[0] == null) {
alert("Please select at least one person to email.");
} else {
for(var c = 0; c < records.length; c++)
{ var contactRecord = sforce.connection.query(
"SELECT Email__c FROM Students_Programs__c WHERE Id ='"+ records[c]+"'");
emailAddresses = emailAddresses + contactRecord.records.Email + ";"; } }
location.replace('/email/author/emailauthor.jsp?retURL=/a0F/o&rtype=003&p24='+emailAddresses);
Java
!=Javascript
email__c
but trying to build upemailAddresses
using fieldemail