Gmail Script Help :: Unique Subject Line & Carbon Copying Recipients

Hi All,

I am using a script in google apps to send emails using spreadsheet data. I have copied and pasted a script from google developers, but I need help customizing it.

I need to have the subject line pull data from a cell within the spreadsheet (subject line will vary), but don't know how to add it into the script. I also need help adding email addresses to carbon copy on the email!

Here is the script I am using ::

function sendEmails() {
  var sheet = SpreadsheetApp.getActiveSheet();
  var startRow = 2;  // First row of data to process
  var numRows = 2;   // Number of rows to process
  // Fetch the range of cells A2:B3
  var dataRange = sheet.getRange(startRow, 1, numRows, 2)
  // Fetch values for each row in the Range.
  var data = dataRange.getValues();
  for (i in data) {
    var row = data[i];
    var emailAddress = row[0];  // First column
    var message = row[1];       // Second column
    var subject = "Sending emails from a Spreadsheet";
    MailApp.sendEmail(emailAddress, subject, message);
  }
}

Cells A1 & B1 are titled "Recipients" & "Email Body" respectively (These cells are inactive and are just Headers)

Cell A2 contains the email address of the recipient.

Cell B2 contains the message that will be sent.

In Cell C2 I would like to add the subject line.

In Cell D2 I would like to add recipients that will be carbon copied.

Your help is greatly appreciated :-)


August 6th, 2014 12:33am

For Google related scripts you should post in the Google developers forum on Google. 

This forum is for Windows administrative scripting with Microsoft products.

Free Windows Admin Tool Kit Click here and download it now
August 6th, 2014 3:02am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics