Solved

google docs script to send email daily with image

Posted on 2012-03-11
7
307 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

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

 
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!

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.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
how can i make the array into an object? 4 33
Forms that calculate points for wordpress 10 29
Hide cell in a table 2 14
how can i get the string decoded ? 2 14
Find out what Office 365 Transport Rules are, how they work and their limitations managing Office 365 signatures.
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.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…

803 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