Created
May 20, 2015 15:52
-
-
Save oshliaer/6f78d7c777787428638b to your computer and use it in GitHub Desktop.
Sends the specified message to the recipients in the To, Cc, and Bcc headers. #gapi #snippet #gmail [not /upload]
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
| function sendMail() { | |
| var email = [ | |
| 'From: John Doe <jdoe@machine.example> ', | |
| 'To: Mary Smith <mary@example.net> ', | |
| 'Subject: Saying Hello ', | |
| 'Date: Fri, 21 Nov 1997 09:55:06 -0600 ', | |
| 'Message-ID: <1234@local.machine.example>', | |
| '', | |
| 'This is a message just to say hello. So, "Hello".' | |
| ].join('\r\n'); | |
| var request = gapi.client.request({ | |
| 'path' : '/gmail/v1/users/me/messages/send', | |
| 'method' : 'POST', | |
| 'body' : { | |
| 'raw' : btoa(email).replace(/\+/g, '-').replace(/\//g, '_') | |
| } | |
| }).then(opt_onFulfilled, opt_onRejected); | |
| } | |
| function opt_onRejected(e) { | |
| console.log(e); | |
| } | |
| function opt_onFulfilled(e) { | |
| console.log(e); | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Users.messages: send