Gmail API decoding messages in Javascript

后端 未结 7 1013
暖寄归人
暖寄归人 2020-12-30 11:07

I am having serious problems decoding the message body of the emails I get using the Gmail API. I want to grab the message content and put the content in a div. I am using a

7条回答
  •  我在风中等你
    2020-12-30 11:40

    I was also annoyed by this point. I discovered a solution through looking at an extension for VSCode. The solution is really simple:

    const body = response.data.payload.body; // the base64 encoded body of a message
     body = Buffer.alloc(
            body.data.length,
            body.data,
            "base64"
          ).toString();  // the decoded message
    

    It worked for me as I was using gmail.users.messages.get() call of Gmail API.

提交回复
热议问题