I'd like to send a Message using Google's Gmail API. I've authenticated successfully, and am trying to use GmailService to send a message.
I'd like to use this:
myService.Users.Messages.Send(myMessage, "me").Execute();
where myService is a Google.Apis.Gmail.v1.GmailService
and myMessage is a Google.Apis.Gmail.v1.Data.Message
.
myService
is fine, I've done the OAuth dance. I can get messages from my Inbox and all that. But I don't know how to construct myMessage
. I have a standard .NET MailMessage
, with human-readable Subject, Body, To, From etc.
But the Google Message
class takes fields Payload
or Raw
. What's the easiest way to convert a full MailMessage
to a string which I can set to the Payload
or Raw
properties? Or is this not what I should be doing at all?