Send Emails with Attachments with Google Apps Script and Mandrill

Gmail sending limits are confined particularly when you are sending messages programmatically as on account of Mail Merge. You can just send two or three hundred messages for each day and afterward you’ve to trust that Google will reset your cutoff.

On the off chance that you might want to send a great many messages yet without the every day limitations, you can consider utilizing an email sending administration like Mandrill. You need a web space and need to confirm the responsibility for area with Mandrill so you are permitted to send messages by means of Mandrill. When confirmed, you get an API key from Mandrill that you can use with Apps Script to send messages in mass without limitations.

Here’s an example bit that sends messages from Google Scripts by means of Mandrill. You likewise need to alternative to incorporate document connections in your messages and these records can be put in a Google Drive organizer. The sendEmail() technique acknowledges both plain content and HTML Mail.

function sendEmail() {

  var MANDRILL_API_KEY = "<<your key here>>";

  var files = [
    "<<Google Drive File ID 1>>",
    "<<Google Drive File ID 2>>",
    "<<Google Drive File ID 3>>"

  var recipients = [
      "email": "",
      "name": "Amit Agarwal",
      "type": "to"
    }, {
      "email": "",
      "type": "cc"
    }, {
      "email": "",
      "type": "bcc"

  var attachments = [];

  for (var f in files) {
    var file = DriveApp.getFileById(files[f]);
      "type": file.getMimeType(),
      "name": file.getName(),
      "content": Utilities.base64Encode(file.getBlob().getBytes())

  var params = {
    "key": MANDRILL_API_KEY,
    "message": {
      "from_email": "<<Sender's Email Address>>",
      "from_name": "<<Sender Name>>",
      "to": recipients,
      "attachments": attachments,
      "headers": {
        "Reply-To": ""
      "subject": "Enter email subject",
      "text"   : "Enter email body in plain text",
      "html"   : "Enter HTML content with <b>tags</b>"

  var response = UrlFetchApp.fetch(
    "", {
      'method': 'POST',
      'payload': JSON.stringify(params),
      'contentType': 'application/json'


It might require some investment to construct your mail space notoriety and thus the messages are lined and not sent immediately. Go to Mandrill Dashboard – Outbound Emails – Activity to see the current status of your sent Emails.

Additionally, it is not, at this point conceivable to send messages from nonexclusive tends to like or since Mandrill requires space possession confirmation to decrease spam messages.

Leave a Comment

Your email address will not be published. Required fields are marked *