How to save image from body email outlook as bytes?

Actually i try to reply email, but if there have images, replied images will error,.
this is my flow:

  1. I get html from body email targeted
  2. i concat string myBodyHTML & obtainedBodyHTML

src image of myBodyHTML is same with src image of obtainedBodyHTML,but error and causes the image not to appear, need to generate src image first i think,

so i want try to get images and save it with bytes then use to myBodyHTML, i dont know its will work or no, but i just want try first… i tried but throw an error, this is my code

image

thanks for help :slight_smile:

Hi,
Easy way of getting it done is just to use a save attachment activity and it will save the embedded image as well.

Thanks,

Hi @Iwan_Kurniawan2

To save images from HTML and use them in another HTML body, you can follow these steps in UiPath:

  1. Use the “Get IMAP Mail Messages” activity to retrieve the email with the HTML body.
  2. Extract the HTML body from the email using the “MailMessage.Body” property and store it in a variable (let’s call it emailBody).
  3. Use the “Matches” activity with the pattern <img[^>]*src="([^"]+)"[^>]*> to extract the image URLs from the emailBody. This will give you a collection of matches.
  4. Iterate through the collection of matches using a “For Each” activity.
  5. Within the loop, use the “HTTP Request” activity to download each image file. Set the “Endpoint” property to the URL obtained from the match.
  6. Save the downloaded image file to a local folder using the “Write Binary File” activity. Specify the file path and use the “Content” property of the “HTTP Request” activity as the input.
  7. Replace the image URL in the emailBody with the local path of the downloaded image file.
  8. Use the modified emailBody as the HTML body for the reply email.

Thanks!!