Retrieve email/message body in html using Gmail API

前端 未结 3 922
耶瑟儿~
耶瑟儿~ 2020-12-07 21:14

Is there any way to retrieve message body in html form using GMail api ?

I have already gone through the message.get docs. Tried changing the format par

3条回答
  •  孤街浪徒
    2020-12-07 22:05

    Both FULL and RAW will return you any text/html parts depending on how you'd like it. If you use FULL you'll get a parsed representation which will be nested json dictionaries that you'll have to walk over looking for the text/html part. If you opt for the RAW format you'll get the entire email in RFC822 format in the Message.raw field. You can pass that to the mime libraries in your chosen language and then use that to find the part you're interested in. Mime is complicated, you'll likely have a top-level "multipart" type with text/html as one of the direct children of it but no guarantees, it's an arbitrarily deep tree structure! :)

提交回复
热议问题