Created
April 11, 2013 16:49
-
-
Save stewartjarod/5365074 to your computer and use it in GitHub Desktop.
Sending email through SendGrid using the SendGrid Node.js Library that includes an attached image using CID. Does not display correctly with Gmail, Yahoo, or Hotmail (such is the nature of CID).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var SendGrid = require('sendgrid').SendGrid; | |
var sendgrid = new SendGrid('username', 'password'); | |
sendgrid.send({ | |
to: '[email protected]', | |
from: '[email protected]', | |
fromname: 'Test Person', | |
subject: 'Hello World', | |
text: 'My first email through SendGrid', | |
html: 'My first email with SendGrid with html <img src="cid:testme" alt="graphic"/>', | |
files: [ | |
{ | |
filename: 'sendgrid_logo-8f6ec9845f58c180692f02f6cb6ec894.png', // required only if file.content is used. | |
url: 'http://sendgrid.com/mkt/assets/sendgrid_logo-8f6ec9845f58c180692f02f6cb6ec894.png', // == One of these three options is required | |
content: ('testme' | Buffer) // | |
} | |
], | |
}, function(success, message) { | |
if (!success) { | |
console.log(message); | |
} | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment