How to parse real src path of img in mail body?

43 Views Asked by At

On Message Compose,I got the email body,The text contains some image information。How to use img's src attribute let me get real image path?

Office.context.mailbox.item.saveAsync(function (result) {
      const itemId = result.value;

      Office.context.mailbox.getCallbackTokenAsync({ isRest: true }, (result) => {
        const token = result.value;

        const apiUrl = Office.context.mailbox.restUrl + "/v2.0/me/messages/" + itemId;

        axios
          .get(apiUrl, {
            headers: {
              Authorization: "Bearer " + token,
            },
          })
          .then((response) => {
            var draftData = response.data.Body.Content;
            console.log(draftData);
          })
          .catch((error) => {
            console.log(error);
          });
      });
    });

I tested calling the above code after adding a few pictures in the message writing scene, and the img of the email body is as follows

<img width="450" height="450" id="图片_x0020_2" src="cid:[email protected]" />

<img width="465" height="467" id="图片_x0020_1" src="cid:[email protected]" />

What do I need to do to turn cid... into a real image path?

1

There are 1 best solutions below

2
Dmitry Streblechenko On

src="cid:xyz" refers to the message attachment with the matching value of the Content-ID MIME property (corresponds to the PR_ATTACH_CONTENTID MAPI property).