title: How to create a Gmail API Message
body: <p>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.</p>
  
  <p>I'd like to use this:</p>
  
  <pre><code>myService.Users.Messages.Send(myMessage, "me").Execute();
  </code></pre>
  
  <p>where myService is a <code>Google.Apis.Gmail.v1.GmailService</code> and myMessage is a <code>Google.Apis.Gmail.v1.Data.Message</code>.</p>
  
  <p><code>myService</code> 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 <code>myMessage</code>. I have a standard .NET <code>MailMessage</code>, with human-readable Subject, Body, To, From etc. </p>
  
  <p>But the Google <code>Message</code> class takes fields <code>Payload</code> or <code>Raw</code>. What's the easiest way to convert a full <code>MailMessage</code> to a string which I can set to the <code>Payload</code> or <code>Raw</code> properties? Or is this not what I should be doing at all?</p>
  
  <p><a href="https://developers.google.com/resources/api-libraries/documentation/gmail/v1/csharp/latest/classGoogle_1_1Apis_1_1Gmail_1_1v1_1_1Data_1_1Message.html" rel="noreferrer">The documentation for the Message class</a>.</p>