I am using cloudmailin and receiving all the reply mails(If someone replies to the emails i send them), now when i do request.raw(), i get all my replies in string format like this:
{
"headers": {
"received": "xxx.google.com with SMTP id c1so1731393vsh.8 for <[email protected]>; Sun, 06 Jun 2021 20:19:02 -0700",
"date": "Mon, 07 Jun 2021 08:48:53 +0530",
"from": "ABC <[email protected]>",
"to": "[email protected]",
"message_id": "<[email protected]>",
"in_reply_to": "<[email protected]>",
"references": "<[email protected]>",
"subject": "Re: Update On Your Ticket #66",
"mime_version": "1.0",
"content_type": "multipart/alternative; boundary=000000000000c465af05c4248031",
"dkim_signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=bD3ONqLV7AId5UzdUHe8gDLobCQrtQFYsq2u/8iYIhk=; b=CEHWz5AC3REury8SN4wyg8wxum9H0CmXqT3XJTOjdP0pa5YpCXHPUDMjjLgYf0upd6 rM7qOI7GGHmzNGATmjxu/iQhRD5VaVxOi/VBrExMwlbFzXz8Dg6PoILI2dDnn5oZuzWi zwujwLEVm7VcY2hetWrJYlBfzL5FtSa5W7gZDH42EyqYTDyzLPhWYBPueCSjqfgbXfWH Wb2roecATRV+W9GQZNF7oOKbvpW5ASjzys7a5Llo2xkVfqlvsJli5aIFlUoY1nozj/v7 D/0zkojKlmyDUGEqRxrcIU8JFPm8gl0Ctnx1GgjiZ2vkvWv9oUNpMZdQU3khTbO8WzSV ss7Q==",
"x_google_dkim_signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to;
bh=bD3ONqLV7AId5UzdUHe8gDLobCQrtQFYsq2u/8iYIhk=; b=Zs0h+EM3gcygNli6sm5CpodTr1kziEkj+W5ceiKiaGo2XZVMOXq85IZBY5jaOUspmF R15pIV36BDP1mI2y0GbRE+jcIq7I6MjIxpDusRrxMDnADYyS5jRNk2YfqJC+4ml2MLSz LGX+4JugPBp4QJq1dDPAGrqP8hfrXNLXcDZx7rUck9LCgbP59nUvDNndYUcbF45xa+oV RvCvYo7ue69ogrc+/DM1b2uzP+lU7oY68yFhpfEGctWGaj36vsOcgrSA+FM7bB0UChWI HVhRwFIzq+tdKH+lJvqMbnxeCSqSL8p0TofGHEKfN4D+POaYVLW59wegz5i7K2Vdpq/l Spog==",
"x_gm_message_state": "AOAM533Hi5baxQtGjkRr4KU1AyKeRfihKQKBKyyQu6Si4uto+Fy8F1jB\tZamxinSc8qQ6vbsNhXqvOvuhBP5iFo23kcz2DEfqY28=",
"x_google_smtp_source": "ABdhPJzSzz9bec+GYLzqjqOWnZ4BOEmm8Yt56FcCc0cr2D6Pag5pWL+Qq2Q7SBXzw+7gBxq1onhFX1KhlhE6yjxuyu4=",
"x_received": "by 2002:a05:6102:dca:: with SMTP id e10mr2789248vst.47.1623035941773; Sun, 06 Jun 2021 20:19:01 -0700 (PDT)"
},
"envelope": {
"to": "[email protected]",
"recipients": [
"[email protected]"
],
"from": "[email protected]",
"helo_domain": "xxx.google.com",
"remote_ip": "abc.de.fg.ql",
"tls": true,
"tls_cipher": "TLSv1.3",
"md5": "xxx",
"spf": {
"result": "neutral",
"domain": "gmail.com"
}
},
"plain": "Yes, what about you?\n\nOn Mon, Jun 7, 2021 at 8:48 AM <[email protected]> wrote:\n\n> [email protected] replied to your ticket\n>\n> Message: all cool?\n>\n",
"html": "<div dir=\"ltr\">Yes, what about you?</div><br><div class=\"gmail_quote\"><div dir=\"ltr\" class=\"gmail_attr\">On Mon, Jun 7, 2021 at 8:48 AM <<a href=\"mailto:[email protected]\">[email protected]</a>> wrote:<br></div><blockquote class=\"gmail_quote\" style=\"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex\"><a href=\"mailto:[email protected]\"
target=\"_blank\">[email protected]</a> replied to your ticket <br><p>Message: all cool?</p>\r\n</blockquote></div>\r\n",
"reply_plain": "Yes, what about you?",
"attachments": [
]
}
how to get only the html
part from this message? I cannot loop through the object as it is a string, from this entire data i want only the html part of the message.
can you help me with this?
Use JSON.parse() to parse the response string to a JSON object. From there, you can use standard property access to get the values you need.
Example: