Search code examples
gmailgoogle-plusgoogle-hangouts

How to send email to people via Google Plus API?


According to Google Plus, you can e-mail Google Plus users within your circle: refer this

  • How can you use the Google Plus API (or Gmail API) to send an e-mail to a user within your circle, given you have their user ID?
  • If you cannot do this, how can you send them a message via hangouts?

Solution

  • You should follow the official Gmail API reference guide here.

    From the docs:

    There are two ways to send email using the Gmail API:

    Emails are sent as base64url encoded strings within the raw property of a message resource. The high-level workflow to send an email is to:

    Create the email content in some convenient way and encode it as a base64url string. Create a new message resource and set its raw property to the base64url string you just created. Call messages.send, or, if sending a draft, drafts.send to send the message.

    The arguments you'll need to provide in order to send an email through the API are the following:

    Args:
        - service: Authorized Gmail API service instance.
        - user_id: User's email address. The special value "me"
                   can be used to indicate the authenticated user.
        - message: Message to be sent.