![]() ![]() If your DRAFT object has just a plain text part or both HTML and plain text parts, the email will be sent and received as expected. If you then call on your DRAFT object, that’s where things get funky. Meaning, you can have a DRAFT containing just a plain text part, or you can have a DRAFT containing just an HTML part, or you can have a DRAFT containing both HTML and plain text parts. If you call and you pass in just a “plain text” part or just an HTML part, then the DRAFT will get created properly with just the part you specified. You can only do this though, if you have OAuth access to the recipient’s Gmail account. If you choose not to “send” an email, but instead to “insert” the email into someone’s Inbox via the API method, then you can set completely different HTML and Text parts and Gmail won’t alter them at all.The better approach would be to sanitize the email, then write it to the user’s “Sent Mail” folder, and simultaneously transmit the email. This is likely a flaw in the API, where it mistakenly writes the email to the user’s “Sent Mail” folder before sanitizing and sending the email. This can fool even the most experienced developer, so it’s important that you don’t rely on what’s in your “Sent Mail” folder as proof of the email that was actually sent. In example #3 above, if you set your own Plain Text part, the “Sent Mail” email will show your HTML parts and Plain Text parts just as you constructed them for the Gmail API, but again, the actual received email will have a different Plain Text part that was auto-generated by Gmail from your HTML part. In example #2 above, if you try to do this, the “Sent Mail” email will show just an HTML part, but the actual received email will have both HTML and Plain Text parts. Lastly, it’s important to know that the message that appears in your account’s “Sent Mail” folder is not the same message that is sent to the receiver.The actual Plain Text part that gets sent will say, “hello there.” Let’s say you construct your email with an HTML part that looks like “hello there” and a Plain Text part that looks like “hi there.” (Notice that one part says “hello,” and the other says “hi.”) When the Gmail API sends your email, your Plain Text part will be wiped out and replaced with a part that is converted from your HTML part. Setting individual HTML and Plain Text parts when constructing your RFC message is useless because the Gmail API will override the Plain Text part with its own Plain Text part, using the HTML part as its basis.If you try to do this, the API will accept the message, but behind the scenes, it will convert your “text/html” part to a “text/plain” part and add that to the message before it sends the email. ![]() You cannot send just an HTML email with the Gmail API, meaning you cannot send a “text/html” part without a corresponding “text/plain” part. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |