0

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:image002.jpg@01D9B4AD.403AFD90" />

<img width="465" height="467" id="图片_x0020_1" src="cid:image001.png@01D9B4AC.2C972DA0" />

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

teleixi
  • 1
  • 1
  • Those `cid:` URIs **are** the "real image paths": `cid:` URIs are references to elements in a `multipart` document (i.e. HTML email). See here: https://stackoverflow.com/questions/922898/embedding-attached-images-in-html-emails – Dai Jul 12 '23 at 06:09
  • Does this answer your question? [Displaying CID Embedded Images from outlook email using the API](https://stackoverflow.com/questions/33612576/displaying-cid-embedded-images-from-outlook-email-using-the-api) – Quentin Jul 12 '23 at 06:12

1 Answers1

1

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).

Dmitry Streblechenko
  • 62,942
  • 4
  • 53
  • 78