Solved

google docs script to send email daily with image

Posted on 2012-03-11
7
313 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
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

PHP contact form that lets the user to contact the company through email contact form. A button is fixed at the bottom of site, on clicking a new window will open where a user can send the email.
Color can increase conversions, create feelings of warmth or even incite people to get behind a cause. If you want your website to really impact site visitors, then it is vital to consider the impact color has on them.
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
This video teaches users how to migrate an existing Wordpress website to a new domain.

837 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