Mail sending either text or html works perfectly fine, but when i send them both in single mail, html comes as an attachment named "noname.html", which contains html.
I have read other related questions on this topic, but couldn't find what is possibly wrong.
MIME-Version: 1.0
From: sender@gmail.com
To: receiver@gmail.com
Subject: test
Content-type: multipart/mixed; boundary="012boundary"
--012boundary
Content-type: text/plain; charset="UTF-8"
Hello plain text!
--012boundary
Content-type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<b>Hello html</b>
--012boundary--`
You want to send both HTML body and text body using gmail API. If my understanding is correct, how about this modification?
From :
To :
Note :
multipart/alternative
, both parts ofContent-type: text/plain; charset="UTF-8"
andContent-type: text/html; charset="UTF-8"
can be sent.Reference :
In my environment, I could confirm that your request body which was modified to
multipart/alternative
worked. If this didn't work on your environment, I'm sorry.Edit :
In order to send a text body, a HTML body and an attachment file of HTML as one email, the structure of request body can be created as follows.
Sample request body :
References :