Search code examples
gmail-api

GMAIL API sending email with attachment in c#


I need help with sending email w/attachment using Gmail Api in c#.

I have read Google website on sending emails with attachment but the example is in java.


Solution

  • There's nothing particular to sending an attachment with the Gmail API. Either way the Gmail API message.send() takes a full RFC822 email message in the message.raw field (urlsafe base64 encoded). The main trick is building up such an RFC822 email message string in your language. I imagine there are some MIME message librarys in C# and that's the main issue is finding those libraries. I don't do C# but javax.internet.mail.MimeMessage works well in java and the 'email' module is good for python.

    This other post seems relevant: How to send multi-part MIME messages in c#?