-2

how to parse img src="~WRS%7b700542CA-4646-8E49-B829-78952E169109%7d.fld/image001.jpg"?I need help,Please tell me。i am a novice,I want to know how to parse the img src attribute in the mail body obtained from Office.context.mailbox.item.getAttachmentContentAsync in add-in on outlook desktop side

I don't how to parse it。

Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45

1 Answers1

0

You can find the required HTML tag in the string and then use the substring() JavaScript function.

Also if you convert the string to the HTMLDocument you can extract the value using the following code:

var imgsrc = document.getElementById('img_tag_id').src;
console.log(imgsrc);

See How to convert an HTML string into an HTML document? for more information.

Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45
  • Hello, thank you very much for answering me, I have tried to get the src, but the obtained src path does not seem to be the real path – Teeeeee Jul 11 '23 at 06:05
  • The src I get when I check the email scene can be parsed, for example: src="cid:image001.png@01D9B357.F2A449C0", but the src I get when replying to the email seems to be encrypted by outlook, for example: src= "~WRS%7bE6D62052-25EC-434B-9BB8-B93D6FAA7D94%7d.fld/image001.jpg", I want to know how to get the real attachment id and the real src path like checking email – Teeeeee Jul 11 '23 at 06:16
  • You are dealing with an embedded image. Such images can be found as attached files to your email. Try to check out the the attachments list with the `PR_ATTACH_CONTENT_ID` MAPI property value specified after the `cid:` prefix. – Eugene Astafiev Jul 11 '23 at 10:15
  • I'm not very clear what you mean, can you give me some examples for reference – Teeeeee Jul 11 '23 at 11:07
  • But the img src in the body I get in reply to the body of the email does not allow me to successfully call Office.context.mailbox.item.getAttachmentContentAsync, for example WRS%7bE6D62052-25EC-434B-9BB8-B93D6FAA7D94%7d.fld/image001.jpg – Teeeeee Jul 11 '23 at 11:16
  • Your original post is about parsing the `src` attribute. If you have any other questions I'd suggest posting new questions in new threads, so users could recognize questions and answers easily. – Eugene Astafiev Jul 11 '23 at 15:29