{"id":10650,"date":"2019-12-11T07:23:01","date_gmt":"2019-12-11T07:23:01","guid":{"rendered":"https:\/\/www.gmass.co\/blog\/?p=10650"},"modified":"2019-12-15T08:15:09","modified_gmt":"2019-12-15T08:15:09","slug":"gmail-api-from-addresses-names","status":"publish","type":"post","link":"https:\/\/www.gmass.co\/blog\/gmail-api-from-addresses-names\/","title":{"rendered":"Developer&#8217;s Guide to the Gmail API and From Addresses\/Names"},"content":{"rendered":"<p>If you&#8217;ve used the Gmail API, you may have encountered some quirks with <strong>From Addressing<\/strong> when creating and sending a <strong>DRAFT<\/strong>. As an example, if you&#8217;re working with a DRAFT in the Gmail UI, and then you change the <strong>From Address<\/strong> to a different choice in the From dropdown in the <strong>Compose<\/strong> window, that change will not immediately be reflected in the DRAFT if you then call <a href=\"https:\/\/developers.google.com\/gmail\/api\/v1\/reference\/users\/drafts\/get\">users.drafts.get<\/a> on that particular DRAFT. Why? Because Gmail hasn&#8217;t saved the DRAFT yet. This is just one of the quirks we&#8217;ll examine and work around in this article.<\/p>\n<h3>1. Create a DRAFT with the Gmail API; then open it up in the UI<\/h3>\n<p>When you create a DRAFT with the API using <a href=\"https:\/\/developers.google.com\/gmail\/api\/v1\/reference\/users\/drafts\/create\">users.drafts.create<\/a>, it doesn&#8217;t necessarily need a From Name\/From Address. But if you then open the DRAFT in the UI and make changes, a <strong>From Display Name<\/strong> will be set. Here is some sample C# where I&#8217;m calling the Gmail API to create a DRAFT with just a <strong>Subject<\/strong> and an <strong>HTML body<\/strong>.<\/p>\n<p><a href=\"https:\/\/www.gmass.co\/blog\/wp-content\/uploads\/2019\/12\/001-subject-and-body-26kb.png\" data-rel=\"lightbox-image-0\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-10753 \" src=\"https:\/\/www.gmass.co\/blog\/wp-content\/uploads\/2019\/12\/001-subject-and-body-26kb.png\" alt=\"\" width=\"611\" height=\"307\" srcset=\"https:\/\/www.gmass.co\/blog\/wp-content\/uploads\/2019\/12\/001-subject-and-body-26kb.png 1172w, https:\/\/www.gmass.co\/blog\/wp-content\/uploads\/2019\/12\/001-subject-and-body-26kb-300x151.png 300w, https:\/\/www.gmass.co\/blog\/wp-content\/uploads\/2019\/12\/001-subject-and-body-26kb-768x385.png 768w, https:\/\/www.gmass.co\/blog\/wp-content\/uploads\/2019\/12\/001-subject-and-body-26kb-1024x514.png 1024w, https:\/\/www.gmass.co\/blog\/wp-content\/uploads\/2019\/12\/001-subject-and-body-26kb-24x12.png 24w, https:\/\/www.gmass.co\/blog\/wp-content\/uploads\/2019\/12\/001-subject-and-body-26kb-36x18.png 36w, https:\/\/www.gmass.co\/blog\/wp-content\/uploads\/2019\/12\/001-subject-and-body-26kb-48x24.png 48w\" sizes=\"auto, (max-width: 611px) 100vw, 611px\" \/><\/a><\/p>\n<p>I can then retrieve the DRAFT that was created by using the Gmail API Explorer. Notice how the From Line contains my account address, ajay@wordzen.com but <strong>no From Name<\/strong>:<\/p>\n<p><a href=\"https:\/\/www.gmass.co\/blog\/wp-content\/uploads\/2019\/12\/002-no-from-name79kb.png\" data-rel=\"lightbox-image-1\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-10757 size-full\" src=\"https:\/\/www.gmass.co\/blog\/wp-content\/uploads\/2019\/12\/002-no-from-name79kb.png\" alt=\"\" width=\"1200\" height=\"888\" srcset=\"https:\/\/www.gmass.co\/blog\/wp-content\/uploads\/2019\/12\/002-no-from-name79kb.png 1200w, https:\/\/www.gmass.co\/blog\/wp-content\/uploads\/2019\/12\/002-no-from-name79kb-300x222.png 300w, https:\/\/www.gmass.co\/blog\/wp-content\/uploads\/2019\/12\/002-no-from-name79kb-768x568.png 768w, https:\/\/www.gmass.co\/blog\/wp-content\/uploads\/2019\/12\/002-no-from-name79kb-1024x758.png 1024w, https:\/\/www.gmass.co\/blog\/wp-content\/uploads\/2019\/12\/002-no-from-name79kb-24x18.png 24w, https:\/\/www.gmass.co\/blog\/wp-content\/uploads\/2019\/12\/002-no-from-name79kb-36x27.png 36w, https:\/\/www.gmass.co\/blog\/wp-content\/uploads\/2019\/12\/002-no-from-name79kb-48x36.png 48w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>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 <strong>From Display Name<\/strong>.<\/p>\n<figure id=\"attachment_10758\" aria-describedby=\"caption-attachment-10758\" style=\"width: 612px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/www.gmass.co\/blog\/wp-content\/uploads\/2019\/12\/003-draft-saves-from-display-name.png\" data-rel=\"lightbox-image-2\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-10758 size-full\" src=\"https:\/\/www.gmass.co\/blog\/wp-content\/uploads\/2019\/12\/003-draft-saves-from-display-name.png\" alt=\"\" width=\"612\" height=\"312\" srcset=\"https:\/\/www.gmass.co\/blog\/wp-content\/uploads\/2019\/12\/003-draft-saves-from-display-name.png 612w, https:\/\/www.gmass.co\/blog\/wp-content\/uploads\/2019\/12\/003-draft-saves-from-display-name-300x153.png 300w, https:\/\/www.gmass.co\/blog\/wp-content\/uploads\/2019\/12\/003-draft-saves-from-display-name-24x12.png 24w, https:\/\/www.gmass.co\/blog\/wp-content\/uploads\/2019\/12\/003-draft-saves-from-display-name-36x18.png 36w, https:\/\/www.gmass.co\/blog\/wp-content\/uploads\/2019\/12\/003-draft-saves-from-display-name-48x24.png 48w\" sizes=\"auto, (max-width: 612px) 100vw, 612px\" \/><\/a><figcaption id=\"caption-attachment-10758\" class=\"wp-caption-text\"><em>I added a &#8220;space&#8221; to the Subject line, and that triggered the saving of the DRAFT, which is reflected in the &#8220;draft saved&#8221; message.<\/em><\/figcaption><\/figure>\n<p>Now if I retrieve the same DRAFT using the API explorer, the From Name is also present in the From Line:<\/p>\n<p><a href=\"https:\/\/www.gmass.co\/blog\/wp-content\/uploads\/2019\/12\/004-From-name-present-on-From-line-69kb.png\" data-rel=\"lightbox-image-3\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-10760 size-full\" src=\"https:\/\/www.gmass.co\/blog\/wp-content\/uploads\/2019\/12\/004-From-name-present-on-From-line-69kb.png\" alt=\"\" width=\"1200\" height=\"760\" srcset=\"https:\/\/www.gmass.co\/blog\/wp-content\/uploads\/2019\/12\/004-From-name-present-on-From-line-69kb.png 1200w, https:\/\/www.gmass.co\/blog\/wp-content\/uploads\/2019\/12\/004-From-name-present-on-From-line-69kb-300x190.png 300w, https:\/\/www.gmass.co\/blog\/wp-content\/uploads\/2019\/12\/004-From-name-present-on-From-line-69kb-768x486.png 768w, https:\/\/www.gmass.co\/blog\/wp-content\/uploads\/2019\/12\/004-From-name-present-on-From-line-69kb-1024x649.png 1024w, https:\/\/www.gmass.co\/blog\/wp-content\/uploads\/2019\/12\/004-From-name-present-on-From-line-69kb-24x15.png 24w, https:\/\/www.gmass.co\/blog\/wp-content\/uploads\/2019\/12\/004-From-name-present-on-From-line-69kb-36x23.png 36w, https:\/\/www.gmass.co\/blog\/wp-content\/uploads\/2019\/12\/004-From-name-present-on-From-line-69kb-48x30.png 48w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/a><\/p>\n<h3>2. Retrieve the From Address\/Name of a DRAFT using the API<\/h3>\n<p>A DRAFT created in the UI will almost always have the correct <strong>From Name<\/strong> and <strong>From Address<\/strong>, however this wasn&#8217;t always the case. For a while after the <a href=\"https:\/\/www.imore.com\/google-introduces-new-gmail-apis-developers\">Gmail API was released in 2014<\/a>, a DRAFT retrieved from the Gmail API would always show the <strong>Google Account Name<\/strong> as the From Name, and not the actual From Name set in <strong>Gmail Settings<\/strong>, or the From Name chosen from the From dropdown in a <strong>Compose<\/strong> window, in the case where multiple From Addresses\/Names are set up. For most users, this was fine, because by default the From Name is NOT set separately in Gmail &#8212; the From Name by default is pulled from your Google Account. It&#8217;s only different if you proactively set it differently in Gmail&#8217;s Settings:<\/p>\n<figure id=\"attachment_10761\" aria-describedby=\"caption-attachment-10761\" style=\"width: 610px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/www.gmass.co\/blog\/wp-content\/uploads\/2019\/12\/005-From-name-Gmail-settings-139kb.png\" data-rel=\"lightbox-image-4\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-10761\" src=\"https:\/\/www.gmass.co\/blog\/wp-content\/uploads\/2019\/12\/005-From-name-Gmail-settings-139kb.png\" alt=\"\" width=\"610\" height=\"319\" srcset=\"https:\/\/www.gmass.co\/blog\/wp-content\/uploads\/2019\/12\/005-From-name-Gmail-settings-139kb.png 1224w, https:\/\/www.gmass.co\/blog\/wp-content\/uploads\/2019\/12\/005-From-name-Gmail-settings-139kb-300x157.png 300w, https:\/\/www.gmass.co\/blog\/wp-content\/uploads\/2019\/12\/005-From-name-Gmail-settings-139kb-768x402.png 768w, https:\/\/www.gmass.co\/blog\/wp-content\/uploads\/2019\/12\/005-From-name-Gmail-settings-139kb-1024x535.png 1024w, https:\/\/www.gmass.co\/blog\/wp-content\/uploads\/2019\/12\/005-From-name-Gmail-settings-139kb-24x13.png 24w, https:\/\/www.gmass.co\/blog\/wp-content\/uploads\/2019\/12\/005-From-name-Gmail-settings-139kb-36x19.png 36w, https:\/\/www.gmass.co\/blog\/wp-content\/uploads\/2019\/12\/005-From-name-Gmail-settings-139kb-48x25.png 48w\" sizes=\"auto, (max-width: 610px) 100vw, 610px\" \/><\/a><figcaption id=\"caption-attachment-10761\" class=\"wp-caption-text\"><em>If you selected the second radio button, you can set the Gmail From Name separately from your Google Account Name.<\/em><\/figcaption><\/figure>\n<p>Additionally, if you had multiple From Addresses\/Names configured for your Gmail account, even if you a From Address other than your default Gmail account, the behavior of the Gmail API method <a href=\"https:\/\/developers.google.com\/gmail\/api\/v1\/reference\/users\/drafts\/get\">users.drafts.get<\/a> was to show the Google Account&#8217;s name in the <strong>From Line<\/strong>, not the specific <strong>From Name<\/strong> that corresponded to the <strong>From Address<\/strong>.<\/p>\n<p>That issue, however, was corrected sometime in 2019. Now, the DRAFT does correctly display the <strong>From Address<\/strong> and the right <strong>From Name<\/strong>, provided it has been saved since the last change was made to the From Address.<\/p>\n<h3>3. Changing the From Address using the dropdown in the Compose doesn&#8217;t always take effect<\/h3>\n<p>When you select a From Address\/Name from the dropdown in the <strong>Compose<\/strong> window, the DRAFT does not save, and the change is therefore not reflected in the DRAFT. Let&#8217;s test this:<\/p>\n<div style=\"position: relative; padding-bottom: 56.25%;\"><iframe style=\"position: absolute; top: 0; left: 0; width: 100%; height: 100%;\" src=\"https:\/\/www.youtube.com\/embed\/Jn0SNQSOipM\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"><\/iframe><\/div>\n<p>&nbsp;<\/p>\n<p>The DRAFT needs to be saved via a change to the <strong>Subject<\/strong> or <strong>Message<\/strong> for the change in the <strong>From dropdown<\/strong> to be reflected in the DRAFT.<\/p>\n<p>Now, does this mean that if you were to click the Gmail Send button after making a change to the From dropdown, that your change wouldn&#8217;t be reflected in the email that is sent? No. Your change would be reflected, because clicking the blue Gmail Send button triggers a &#8220;save&#8221; operation on the DRAFT before it&#8217;s sent.<\/p>\n<p>Similar to how the blue Send button triggers the saving of the DRAFT, you can also trigger the saving of a DRAFT programmatically. If you&#8217;re developing a Chrome extension and using JavaScript and the <a href=\"https:\/\/www.inboxsdk.com\/\">Inbox SDK API<\/a> to manipulate the Gmail UI, then you can use the <strong>fromContactChanged<\/strong> event to detect when a change has been made, and then forcibly add a &#8220;space&#8221; to the <strong>Subject<\/strong> Line to force the DRAFT to save in a few seconds.<\/p>\n<p><a href=\"https:\/\/www.gmass.co\/blog\/wp-content\/uploads\/2019\/12\/006-Inbox-SDK-FromContactChanged-75kb.png\" data-rel=\"lightbox-image-5\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-10763 size-full\" src=\"https:\/\/www.gmass.co\/blog\/wp-content\/uploads\/2019\/12\/006-Inbox-SDK-FromContactChanged-75kb.png\" alt=\"\" width=\"1224\" height=\"412\" srcset=\"https:\/\/www.gmass.co\/blog\/wp-content\/uploads\/2019\/12\/006-Inbox-SDK-FromContactChanged-75kb.png 1224w, https:\/\/www.gmass.co\/blog\/wp-content\/uploads\/2019\/12\/006-Inbox-SDK-FromContactChanged-75kb-300x101.png 300w, https:\/\/www.gmass.co\/blog\/wp-content\/uploads\/2019\/12\/006-Inbox-SDK-FromContactChanged-75kb-768x259.png 768w, https:\/\/www.gmass.co\/blog\/wp-content\/uploads\/2019\/12\/006-Inbox-SDK-FromContactChanged-75kb-1024x345.png 1024w, https:\/\/www.gmass.co\/blog\/wp-content\/uploads\/2019\/12\/006-Inbox-SDK-FromContactChanged-75kb-24x8.png 24w, https:\/\/www.gmass.co\/blog\/wp-content\/uploads\/2019\/12\/006-Inbox-SDK-FromContactChanged-75kb-36x12.png 36w, https:\/\/www.gmass.co\/blog\/wp-content\/uploads\/2019\/12\/006-Inbox-SDK-FromContactChanged-75kb-48x16.png 48w\" sizes=\"auto, (max-width: 1224px) 100vw, 1224px\" \/><\/a><\/p>\n<p>Here&#8217;s a code sample to accomplish this:<\/p>\n<p><a href=\"https:\/\/www.gmass.co\/blog\/wp-content\/uploads\/2019\/12\/007-FromContactChanged-code-122kb.png\" data-rel=\"lightbox-image-6\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-10764\" src=\"https:\/\/www.gmass.co\/blog\/wp-content\/uploads\/2019\/12\/007-FromContactChanged-code-122kb.png\" alt=\"\" width=\"609\" height=\"159\" srcset=\"https:\/\/www.gmass.co\/blog\/wp-content\/uploads\/2019\/12\/007-FromContactChanged-code-122kb.png 1224w, https:\/\/www.gmass.co\/blog\/wp-content\/uploads\/2019\/12\/007-FromContactChanged-code-122kb-300x78.png 300w, https:\/\/www.gmass.co\/blog\/wp-content\/uploads\/2019\/12\/007-FromContactChanged-code-122kb-768x201.png 768w, https:\/\/www.gmass.co\/blog\/wp-content\/uploads\/2019\/12\/007-FromContactChanged-code-122kb-1024x268.png 1024w, https:\/\/www.gmass.co\/blog\/wp-content\/uploads\/2019\/12\/007-FromContactChanged-code-122kb-24x6.png 24w, https:\/\/www.gmass.co\/blog\/wp-content\/uploads\/2019\/12\/007-FromContactChanged-code-122kb-36x9.png 36w, https:\/\/www.gmass.co\/blog\/wp-content\/uploads\/2019\/12\/007-FromContactChanged-code-122kb-48x13.png 48w\" sizes=\"auto, (max-width: 609px) 100vw, 609px\" \/><\/a><\/p>\n<h3>4. Retrieve account-wide From Address info<\/h3>\n<p>Another way you can retrieve From Line information is by using the <strong>users.settings.sendAs<\/strong> methods of the API. The &#8220;list&#8221; method will pull a list of all possible From Addresses\/Names from the account, not specific to a DRAFT, though. The information here corresponds to the information under your <strong>Settings&#8211;&gt;Accounts<\/strong> tab in the Gmail web interface:<\/p>\n<figure id=\"attachment_10765\" aria-describedby=\"caption-attachment-10765\" style=\"width: 1224px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/www.gmass.co\/blog\/wp-content\/uploads\/2019\/12\/008-Settings-list-method-for-From-address-47kb.png\" data-rel=\"lightbox-image-7\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-10765 size-full\" src=\"https:\/\/www.gmass.co\/blog\/wp-content\/uploads\/2019\/12\/008-Settings-list-method-for-From-address-47kb.png\" alt=\"\" width=\"1224\" height=\"536\" srcset=\"https:\/\/www.gmass.co\/blog\/wp-content\/uploads\/2019\/12\/008-Settings-list-method-for-From-address-47kb.png 1224w, https:\/\/www.gmass.co\/blog\/wp-content\/uploads\/2019\/12\/008-Settings-list-method-for-From-address-47kb-300x131.png 300w, https:\/\/www.gmass.co\/blog\/wp-content\/uploads\/2019\/12\/008-Settings-list-method-for-From-address-47kb-768x336.png 768w, https:\/\/www.gmass.co\/blog\/wp-content\/uploads\/2019\/12\/008-Settings-list-method-for-From-address-47kb-1024x448.png 1024w, https:\/\/www.gmass.co\/blog\/wp-content\/uploads\/2019\/12\/008-Settings-list-method-for-From-address-47kb-24x11.png 24w, https:\/\/www.gmass.co\/blog\/wp-content\/uploads\/2019\/12\/008-Settings-list-method-for-From-address-47kb-36x16.png 36w, https:\/\/www.gmass.co\/blog\/wp-content\/uploads\/2019\/12\/008-Settings-list-method-for-From-address-47kb-48x21.png 48w\" sizes=\"auto, (max-width: 1224px) 100vw, 1224px\" \/><\/a><figcaption id=\"caption-attachment-10765\" class=\"wp-caption-text\"><em>This is the list of From Addresses and corresponding Display Names I&#8217;ve configured for my Gmail account.<\/em><\/figcaption><\/figure>\n<p>There&#8217;s one key difference, though, that&#8217;s important to be aware of if you plan on retrieving From Line information using the <a href=\"https:\/\/developers.google.com\/gmail\/api\/v1\/reference\/users\/settings\/sendAs\/list\">Users.settings.sendAs.list<\/a> method. If you have set your default Gmail account to use the From Name of your Google account, meaning you haven&#8217;t set it separately in Gmail settings, then the API will return an <strong>empty string<\/strong> for the <strong>From Display Name<\/strong>.<\/p>\n<p>Let&#8217;s demonstrate this by video:<\/p>\n<div style=\"position: relative; padding-bottom: 56.25%;\"><iframe style=\"position: absolute; top: 0; left: 0; width: 100%; height: 100%;\" src=\"https:\/\/www.youtube.com\/embed\/Byo3d4HPDD8\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"><\/iframe><\/div>\n<h3>5. Working client-side? Use the Inbox SDK API to pull the From Line from the Gmail web UI.<\/h3>\n<p>If you&#8217;re working with Gmail inside the interface and are developing a Chrome extension and want to get the current DRAFT&#8217;s <strong>From Address<\/strong> and <strong>Display Name<\/strong>, you can also use <strong>Inbox SDK&#8217;s API<\/strong>, and specifically, the <a href=\"https:\/\/www.inboxsdk.com\/docs\/#ComposeView\">getFromContact method<\/a> of the <strong>ComposeView<\/strong> object. A <strong>ComposeView<\/strong> is just a fancy term for an actual <strong>Compose<\/strong> window in Gmail.<\/p>\n<p>However, there&#8217;s an important factor to consider when using the <strong>getFromContact<\/strong>\u00a0method. If your Gmail account <em>doesn&#8217;t have any additional From Addresses<\/em> set up, meaning <strong>all your emails are sent by your default Gmail account<\/strong>, then <em>a From dropdown doesn&#8217;t show up in the Compose window<\/em>.<\/p>\n<figure id=\"attachment_10767\" aria-describedby=\"caption-attachment-10767\" style=\"width: 612px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/www.gmass.co\/blog\/wp-content\/uploads\/2019\/12\/009-From-line-from-Gmail-web-UI-45kb.png\" data-rel=\"lightbox-image-8\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-10767\" src=\"https:\/\/www.gmass.co\/blog\/wp-content\/uploads\/2019\/12\/009-From-line-from-Gmail-web-UI-45kb.png\" alt=\"\" width=\"612\" height=\"343\" srcset=\"https:\/\/www.gmass.co\/blog\/wp-content\/uploads\/2019\/12\/009-From-line-from-Gmail-web-UI-45kb.png 1181w, https:\/\/www.gmass.co\/blog\/wp-content\/uploads\/2019\/12\/009-From-line-from-Gmail-web-UI-45kb-300x168.png 300w, https:\/\/www.gmass.co\/blog\/wp-content\/uploads\/2019\/12\/009-From-line-from-Gmail-web-UI-45kb-768x430.png 768w, https:\/\/www.gmass.co\/blog\/wp-content\/uploads\/2019\/12\/009-From-line-from-Gmail-web-UI-45kb-1024x574.png 1024w, https:\/\/www.gmass.co\/blog\/wp-content\/uploads\/2019\/12\/009-From-line-from-Gmail-web-UI-45kb-24x13.png 24w, https:\/\/www.gmass.co\/blog\/wp-content\/uploads\/2019\/12\/009-From-line-from-Gmail-web-UI-45kb-36x20.png 36w, https:\/\/www.gmass.co\/blog\/wp-content\/uploads\/2019\/12\/009-From-line-from-Gmail-web-UI-45kb-48x27.png 48w\" sizes=\"auto, (max-width: 612px) 100vw, 612px\" \/><\/a><figcaption id=\"caption-attachment-10767\" class=\"wp-caption-text\"><em>If you don&#8217;t have any additional From Addresses set up in your Gmail account, then a Compose window doesn&#8217;t give you a From dropdown.<\/em><\/figcaption><\/figure>\n<p>If there&#8217;s no From dropdown, then <strong>getFromContact<\/strong> has difficulty pulling accurate From Line information for the ComposeView. <em>It can&#8217;t find what it can&#8217;t see.<\/em><\/p>\n<p>If there&#8217;s no From dropdown, then the properties of the\u00a0 <a href=\"https:\/\/www.inboxsdk.com\/docs\/#Contact\">Contact object<\/a> it retrieves are set to your logged-in Gmail account. <strong>Contact.name<\/strong> is set to the Name set for your overall Google account, and <strong>Contact.emailAddress<\/strong> is set to your logged-in Gmail account. Sometimes, it&#8217;s unable to pull the name set on your Google Account and instead sets Contact.name to &#8220;Default&#8221;. In the past, this has caused issues for GMass users, but we&#8217;ve now worked around this by ceasing our use of getFromContact and relying on the From Address\/Name in the Gmail DRAFT retrieved from the API instead. Essentially, we&#8217;ve moved the processing from the front-end to the back-end to ensure greater accuracy.<\/p>\n<h3>TL; DR<\/h3>\n<p>There are several techniques to pull From Email and From Display Name information from a Gmail DRAFT and from an overall Gmail account, but there are some oddities to take into consideration.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you&#8217;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&#8217;re working with\u2026<\/p>\n","protected":false},"author":2,"featured_media":10770,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[3462,2293,5916],"tags":[],"class_list":["post-10650","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-developers","category-from-address","category-gmail-api"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\r\n<title>Developer&#039;s Guide to the Gmail API and From Addresses\/Names<\/title>\r\n<meta name=\"description\" content=\"Using the Gmail API to retrieve From Address\/Name information for Drafts and Messages comes along with some idiosyncrasies. Here&#039;s how to deal with them.\" \/>\r\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\r\n<link rel=\"canonical\" href=\"https:\/\/www.gmass.co\/blog\/gmail-api-from-addresses-names\/\" \/>\r\n<meta property=\"og:locale\" content=\"en_US\" \/>\r\n<meta property=\"og:type\" content=\"article\" \/>\r\n<meta property=\"og:title\" content=\"Developer&#039;s Guide to the Gmail API and From Addresses\/Names\" \/>\r\n<meta property=\"og:description\" content=\"Using the Gmail API to retrieve From Address\/Name information for Drafts and Messages comes along with some idiosyncrasies. Here&#039;s how to deal with them.\" \/>\r\n<meta property=\"og:url\" content=\"https:\/\/www.gmass.co\/blog\/gmail-api-from-addresses-names\/\" \/>\r\n<meta property=\"og:site_name\" content=\"GMass Blog\" \/>\r\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/GmailMailMerge\/\" \/>\r\n<meta property=\"article:published_time\" content=\"2019-12-11T07:23:01+00:00\" \/>\r\n<meta property=\"article:modified_time\" content=\"2019-12-15T08:15:09+00:00\" \/>\r\n<meta property=\"og:image\" content=\"https:\/\/www.gmass.co\/blog\/wp-content\/uploads\/2019\/12\/Gmail-Dev-Guide-001-65kb.png\" \/>\r\n\t<meta property=\"og:image:width\" content=\"2002\" \/>\r\n\t<meta property=\"og:image:height\" content=\"934\" \/>\r\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\r\n<meta name=\"author\" content=\"Ajay Goel\" \/>\r\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\r\n<meta name=\"twitter:creator\" content=\"@PartTimeSnob\" \/>\r\n<meta name=\"twitter:site\" content=\"@GMassForGmail\" \/>\r\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Ajay Goel\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\r\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.gmass.co\\\/blog\\\/gmail-api-from-addresses-names\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.gmass.co\\\/blog\\\/gmail-api-from-addresses-names\\\/\"},\"author\":{\"name\":\"Ajay Goel\",\"@id\":\"https:\\\/\\\/www.gmass.co\\\/blog\\\/#\\\/schema\\\/person\\\/b5fa74f8765b860701158fd77162fff8\"},\"headline\":\"Developer&#8217;s Guide to the Gmail API and From Addresses\\\/Names\",\"datePublished\":\"2019-12-11T07:23:01+00:00\",\"dateModified\":\"2019-12-15T08:15:09+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.gmass.co\\\/blog\\\/gmail-api-from-addresses-names\\\/\"},\"wordCount\":1300,\"commentCount\":4,\"image\":{\"@id\":\"https:\\\/\\\/www.gmass.co\\\/blog\\\/gmail-api-from-addresses-names\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.gmass.co\\\/blog\\\/wp-content\\\/uploads\\\/2019\\\/12\\\/Gmail-Dev-Guide-001-65kb.png\",\"articleSection\":[\"Developers\",\"From Address\",\"Gmail API\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.gmass.co\\\/blog\\\/gmail-api-from-addresses-names\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.gmass.co\\\/blog\\\/gmail-api-from-addresses-names\\\/\",\"url\":\"https:\\\/\\\/www.gmass.co\\\/blog\\\/gmail-api-from-addresses-names\\\/\",\"name\":\"Developer's Guide to the Gmail API and From Addresses\\\/Names\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.gmass.co\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.gmass.co\\\/blog\\\/gmail-api-from-addresses-names\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.gmass.co\\\/blog\\\/gmail-api-from-addresses-names\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.gmass.co\\\/blog\\\/wp-content\\\/uploads\\\/2019\\\/12\\\/Gmail-Dev-Guide-001-65kb.png\",\"datePublished\":\"2019-12-11T07:23:01+00:00\",\"dateModified\":\"2019-12-15T08:15:09+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.gmass.co\\\/blog\\\/#\\\/schema\\\/person\\\/b5fa74f8765b860701158fd77162fff8\"},\"description\":\"Using the Gmail API to retrieve From Address\\\/Name information for Drafts and Messages comes along with some idiosyncrasies. Here's how to deal with them.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.gmass.co\\\/blog\\\/gmail-api-from-addresses-names\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.gmass.co\\\/blog\\\/gmail-api-from-addresses-names\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.gmass.co\\\/blog\\\/gmail-api-from-addresses-names\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.gmass.co\\\/blog\\\/wp-content\\\/uploads\\\/2019\\\/12\\\/Gmail-Dev-Guide-001-65kb.png\",\"contentUrl\":\"https:\\\/\\\/www.gmass.co\\\/blog\\\/wp-content\\\/uploads\\\/2019\\\/12\\\/Gmail-Dev-Guide-001-65kb.png\",\"width\":2002,\"height\":934},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.gmass.co\\\/blog\\\/gmail-api-from-addresses-names\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.gmass.co\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Developer&#8217;s Guide to the Gmail API and From Addresses\\\/Names\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.gmass.co\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.gmass.co\\\/blog\\\/\",\"name\":\"GMass Blog\",\"description\":\"Tips and tricks for sending mail merge and mass email campaigns directly from Gmail\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.gmass.co\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.gmass.co\\\/blog\\\/#\\\/schema\\\/person\\\/b5fa74f8765b860701158fd77162fff8\",\"name\":\"Ajay Goel\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/f3a70af05bbabe47925150d5a1320540e801b78055a74da20658fc97cd0706a2?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/f3a70af05bbabe47925150d5a1320540e801b78055a74da20658fc97cd0706a2?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/f3a70af05bbabe47925150d5a1320540e801b78055a74da20658fc97cd0706a2?s=96&d=mm&r=g\",\"caption\":\"Ajay Goel\"},\"description\":\"Ajay is the founder of GMass and has been developing email sending software for 20 years.\",\"sameAs\":[\"https:\\\/\\\/twitter.com\\\/PartTimeSnob\",\"https:\\\/\\\/x.com\\\/PartTimeSnob\"],\"url\":\"https:\\\/\\\/www.gmass.co\\\/blog\\\/author\\\/ajay-goel\\\/\"}]}<\/script>\r\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Developer's Guide to the Gmail API and From Addresses\/Names","description":"Using the Gmail API to retrieve From Address\/Name information for Drafts and Messages comes along with some idiosyncrasies. Here's how to deal with them.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.gmass.co\/blog\/gmail-api-from-addresses-names\/","og_locale":"en_US","og_type":"article","og_title":"Developer's Guide to the Gmail API and From Addresses\/Names","og_description":"Using the Gmail API to retrieve From Address\/Name information for Drafts and Messages comes along with some idiosyncrasies. Here's how to deal with them.","og_url":"https:\/\/www.gmass.co\/blog\/gmail-api-from-addresses-names\/","og_site_name":"GMass Blog","article_publisher":"https:\/\/www.facebook.com\/GmailMailMerge\/","article_published_time":"2019-12-11T07:23:01+00:00","article_modified_time":"2019-12-15T08:15:09+00:00","og_image":[{"width":2002,"height":934,"url":"https:\/\/www.gmass.co\/blog\/wp-content\/uploads\/2019\/12\/Gmail-Dev-Guide-001-65kb.png","type":"image\/png"}],"author":"Ajay Goel","twitter_card":"summary_large_image","twitter_creator":"@PartTimeSnob","twitter_site":"@GMassForGmail","twitter_misc":{"Written by":"Ajay Goel","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.gmass.co\/blog\/gmail-api-from-addresses-names\/#article","isPartOf":{"@id":"https:\/\/www.gmass.co\/blog\/gmail-api-from-addresses-names\/"},"author":{"name":"Ajay Goel","@id":"https:\/\/www.gmass.co\/blog\/#\/schema\/person\/b5fa74f8765b860701158fd77162fff8"},"headline":"Developer&#8217;s Guide to the Gmail API and From Addresses\/Names","datePublished":"2019-12-11T07:23:01+00:00","dateModified":"2019-12-15T08:15:09+00:00","mainEntityOfPage":{"@id":"https:\/\/www.gmass.co\/blog\/gmail-api-from-addresses-names\/"},"wordCount":1300,"commentCount":4,"image":{"@id":"https:\/\/www.gmass.co\/blog\/gmail-api-from-addresses-names\/#primaryimage"},"thumbnailUrl":"https:\/\/www.gmass.co\/blog\/wp-content\/uploads\/2019\/12\/Gmail-Dev-Guide-001-65kb.png","articleSection":["Developers","From Address","Gmail API"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.gmass.co\/blog\/gmail-api-from-addresses-names\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.gmass.co\/blog\/gmail-api-from-addresses-names\/","url":"https:\/\/www.gmass.co\/blog\/gmail-api-from-addresses-names\/","name":"Developer's Guide to the Gmail API and From Addresses\/Names","isPartOf":{"@id":"https:\/\/www.gmass.co\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.gmass.co\/blog\/gmail-api-from-addresses-names\/#primaryimage"},"image":{"@id":"https:\/\/www.gmass.co\/blog\/gmail-api-from-addresses-names\/#primaryimage"},"thumbnailUrl":"https:\/\/www.gmass.co\/blog\/wp-content\/uploads\/2019\/12\/Gmail-Dev-Guide-001-65kb.png","datePublished":"2019-12-11T07:23:01+00:00","dateModified":"2019-12-15T08:15:09+00:00","author":{"@id":"https:\/\/www.gmass.co\/blog\/#\/schema\/person\/b5fa74f8765b860701158fd77162fff8"},"description":"Using the Gmail API to retrieve From Address\/Name information for Drafts and Messages comes along with some idiosyncrasies. Here's how to deal with them.","breadcrumb":{"@id":"https:\/\/www.gmass.co\/blog\/gmail-api-from-addresses-names\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.gmass.co\/blog\/gmail-api-from-addresses-names\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.gmass.co\/blog\/gmail-api-from-addresses-names\/#primaryimage","url":"https:\/\/www.gmass.co\/blog\/wp-content\/uploads\/2019\/12\/Gmail-Dev-Guide-001-65kb.png","contentUrl":"https:\/\/www.gmass.co\/blog\/wp-content\/uploads\/2019\/12\/Gmail-Dev-Guide-001-65kb.png","width":2002,"height":934},{"@type":"BreadcrumbList","@id":"https:\/\/www.gmass.co\/blog\/gmail-api-from-addresses-names\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.gmass.co\/blog\/"},{"@type":"ListItem","position":2,"name":"Developer&#8217;s Guide to the Gmail API and From Addresses\/Names"}]},{"@type":"WebSite","@id":"https:\/\/www.gmass.co\/blog\/#website","url":"https:\/\/www.gmass.co\/blog\/","name":"GMass Blog","description":"Tips and tricks for sending mail merge and mass email campaigns directly from Gmail","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.gmass.co\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.gmass.co\/blog\/#\/schema\/person\/b5fa74f8765b860701158fd77162fff8","name":"Ajay Goel","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/f3a70af05bbabe47925150d5a1320540e801b78055a74da20658fc97cd0706a2?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/f3a70af05bbabe47925150d5a1320540e801b78055a74da20658fc97cd0706a2?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/f3a70af05bbabe47925150d5a1320540e801b78055a74da20658fc97cd0706a2?s=96&d=mm&r=g","caption":"Ajay Goel"},"description":"Ajay is the founder of GMass and has been developing email sending software for 20 years.","sameAs":["https:\/\/twitter.com\/PartTimeSnob","https:\/\/x.com\/PartTimeSnob"],"url":"https:\/\/www.gmass.co\/blog\/author\/ajay-goel\/"}]}},"_links":{"self":[{"href":"https:\/\/www.gmass.co\/blog\/wp-json\/wp\/v2\/posts\/10650","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.gmass.co\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gmass.co\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gmass.co\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gmass.co\/blog\/wp-json\/wp\/v2\/comments?post=10650"}],"version-history":[{"count":26,"href":"https:\/\/www.gmass.co\/blog\/wp-json\/wp\/v2\/posts\/10650\/revisions"}],"predecessor-version":[{"id":10771,"href":"https:\/\/www.gmass.co\/blog\/wp-json\/wp\/v2\/posts\/10650\/revisions\/10771"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.gmass.co\/blog\/wp-json\/wp\/v2\/media\/10770"}],"wp:attachment":[{"href":"https:\/\/www.gmass.co\/blog\/wp-json\/wp\/v2\/media?parent=10650"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gmass.co\/blog\/wp-json\/wp\/v2\/categories?post=10650"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gmass.co\/blog\/wp-json\/wp\/v2\/tags?post=10650"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}