Developer’s Guide to the Gmail API and From Addresses/Names

Discuss topics related to the USA Database.
Post Reply
batasakas
Posts: 124
Joined: Mon Dec 09, 2024 3:49 am

Developer’s Guide to the Gmail API and From Addresses/Names

Post by batasakas »

If you’ve used the Gmail API, you may have encountered some quirks with From Addressing when creating and sending a DRAFT. As an example, if you’re working with a DRAFT in the Gmail UI, and then you change the From Address to a different choice in the From dropdown in the Compose window, that change will not immediately be reflected in the DRAFT if you then call users.drafts.get on that particular DRAFT. Why? Because Gmail hasn’t saved the DRAFT yet. This is just one of the quirks we’ll examine and work around in this article.

1. Create a DRAFT with the Gmail API; then open it up in the UI
When you create a DRAFT with the API using users.drafts.create, it doesn’t necessarily need a georgia phone number material From Name/From Address. But if you then open the DRAFT in the UI and make changes, a From Display Name will be set. Here is some sample C# where I’m calling the Gmail API to create a DRAFT with just a Subject and an HTML body.

Image

I can then retrieve the DRAFT that was created by using the Gmail API Explorer. Notice how the From Line contains my account address, [email protected] but no From Name:


However, if I then open up this DRAFT in the Gmail web interface, and then make a simple change like adding a few spaces to the Subject, that action re-saves the DRAFT and also sets the From Display Name.
Post Reply