Solved

google docs script to send email daily with image

Posted on 2012-03-11
7
304 Views
Last Modified: 2012-10-04
Hi!
I'm using this script in a google doc to send myself an email every day.
How can I include an image in the body of the email?
Thanks!
function myFunction() {
  var subject = "message";
  var message = "This email was sent at " + new Date();
  var recipient = "xxx@gmail.com";

  MailApp.sendEmail(recipient, subject, message );
}

Open in new window

0
Comment
Question by:etech0
  • 5
  • 2
7 Comments
 
LVL 1

Expert Comment

by:ravi_kaalla
ID: 37712643
function myFunction() {
  var subject = "message";
  var message = "This email was sent at " + new Date();
  message += "<img src='smiley.gif' alt='Smiley face' height='42' width='42'/>"
  var recipient = "xxx@gmail.com";

  MailApp.sendEmail(recipient, subject, message );
}

Open in new window

0
 
LVL 10

Author Comment

by:etech0
ID: 37716762
Thanks! How can I tell it where to find the image?
0
 
LVL 1

Accepted Solution

by:
ravi_kaalla earned 500 total points
ID: 37718361
you can mention the image path in the "src" attribute

function myFunction() {
  var subject = "message";
  var message = "This email was sent at " + new Date();
  message += "<img src='http://www.google.com/images/srpr/logo3w.png' alt='Smiley face' height='42' width='42'/>"
  var recipient = "xxx@gmail.com";

  MailApp.sendEmail(recipient, subject, message );
}

Open in new window

0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 10

Author Comment

by:etech0
ID: 37721617
What if the file is on my computer?
0
 
LVL 10

Author Comment

by:etech0
ID: 37739570
Okay, I put the file in my Dropbox, so google can access it.
Now, I get an email that contains the following:

This email was sent at Mon Mar 19 2012 16:24:15 GMT-0400 (EDT)<img src='http://dl.dropbox.com/u/58086246/memvav.png' alt='Mem Vav'  
width='420'/>

I don't see the image at all.
Why could this be?

Here is my function (with email address changed):

function myFunction() {
  var subject = "This should be for a...";
  var message = "This email was sent at " + new Date();
  message += "<img src='http://dl.dropbox.com/u/58086246/memvav.png' alt='Mem Vav' width='420'/>"
  var recipient = "xxx@gmail.com";

  MailApp.sendEmail(recipient, subject, message );
}

Open in new window

0
 
LVL 10

Author Comment

by:etech0
ID: 37761785
It looks like the email contains the 'text' of html, but is not formatted as html. Why could this be?
0
 
LVL 10

Author Comment

by:etech0
ID: 38416333
Anyone out there?
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Follow this checklist to learn more about the 15 things you should never include in an email signature from personal quotes, animated gifs and out-of-date marketing content.
Get to know the ins and outs of building a web-based ERP system for your enterprise. Development timeline, technology, and costs outlined.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now