I\'m trying to create drafts in Gmail using the .Net Client Library. I can successfully login and retrieve a list of drafts so the authentication and api are working. Now I
Using the client library you can set the base64 encoded email to the raw property of a Message then use that Message as the message property of the Draft.
More generally: The Draft Message consists of an id and a Message Resource https://developers.google.com/gmail/api/v1/reference/users/drafts
{
"id": string,
"message": users.messages Resource
}
The Message Resource should have its "raw" field set to a base64 encoded RCF 2822 formatted string.
Eg:
from: me@email.com
to: you@email.com
subject: test email
email body
As a base64 encoded string is:
ZnJvbTogbWVAZW1haWwuY29tDQp0bzogeW91QGVtYWlsLmNvbQ0Kc3ViamVjdDogdGVzdCBlbWFpbA0KDQplbWFpbCBib2R5
So the request body of a draft.create should look something like:
{
"message": {
"raw": "ZnJvbTogbWVAZW1haWwuY29tDQp0bzogeW91QGVtYWlsLmNvbQ0Kc3ViamVjdDogdGVzdCBlbWFpbA0KDQplbWFpbCBib2R5"
}
}