Sending mail with attachment
See original GitHub issueHow to send a email with attachment using gmail api? am able to send mail successfully without an attachment,but am not getting how to attach a file and send the mail…can anyone please help me on this .
following is the snippet am using for sending a mail with out attachment
function sendMessage(auth) {
var gmail =google.gmail('v1');
var email_lines =[];
email_lines.push("From: abc@gmail.com");
email_lines.push("To:abc@gmail.com ");
email_lines.push('Content-type: text/html;charset=iso-8859-1');
email_lines.push('MIME-Version: 1.0');
email_lines.push("Subject: Testing ");
email_lines.push("");
email_lines.push("hai");
email_lines.push("<b>And henge naavu</b>");
var email =email_lines.join("\r\n").trim();
var base64EncodedEmail = new Buffer(email).toString('base64');
base64EncodedEmail= base64EncodedEmail.replace(/\//g,'_').replace(/\+/g,'-');
gmail.users.messages.send({
auth:auth,
'userId': 'me',
'resource': {
'raw': base64EncodedEmail
}
},function(err, response) {
if (err) {
console.log('The API returned an error: ' + err);
return;
}
console.log(response);
});
Thanks in advance
Issue Analytics
- State:
- Created 8 years ago
- Reactions:1
- Comments:13 (2 by maintainers)
Top Results From Across the Web
How To Write an Email With an Attachment (With Examples)
1. Determine what files you wish to send · 2. Write the email's subject line · 3. Compose the email's body · 4....
Read more >How to Send an Email with an Attachment (for Beginners)
But people who are new to email might not yet know how to attach and send files in email. Here are some beginner...
Read more >Sending an email with an attachment - IBM
Procedure · Switch to the Integration Development perspective. · Add an EmailOutput node to your message flow. · Edit the following properties of ......
Read more >How to Craft The Perfect Email with Attachments (Examples ...
An email attachment is a file accompanying an outgoing email that provides additional content not covered in your email body. The extra ...
Read more >How to Send Email Attachments and Best Practices to Follow
Steps to send emails with attachments in Outlook · On your PC, go to Outlook. · Click New Message. · After composing your...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Here is the solution that worked for me,
function makeBody(subject, message) { var boundary =
"__myapp__"
; var nl = “\n”; var attach = new Buffer(fs.readFileSync(__dirname + “/…/”+fileName)) .toString(“base64”); // console.dir(attach); var str = [Why isn’t there an example of such basic functionality anywhere? I’ve been spending 4 hours trying to send a mail with an attachment. Impossible.