I want to replace src of 1st img tag with index 0 of attachments array, 2nd tag with index 1 so on and so forth without using jQuery. The html in stored inside a variable.
var body="<div dir="ltr">
text above image
<div>
<img src="cid:ii_ksc42giw0" alt="IMG_20210814_124816.jpg" width="407"
height="542"><br>
<img src="cid:ii_ksc41siq0" alt="IMG_20210814_124816.jpg" width="407"
height="542"><br>
</div>
<div>
text below image
</div>
</div>"
var attachments = ['https://some-random-url-1', 'https://some-random-url-2']