Send image in mail body using SMTP mail message activity


I am able to send the image using SMTP mail message activity.
But i have shared the above image, in that image in the body is very small, I need it bigger, user able to see when open the mail.
Body (as html)="

Hi Team,

Please find the process status distribution chart below:



Regards,
Bot

" Note: Image_path="C:\Users\Admin\Desktop\UiPath Workflows\Email Automation\StatusChart.png Help me, i need the image in the body is bigger size.

Html body:

@Vanitha_VS You can control the image size using the width or style attribute in the tag. Also, instead of using only Path.GetFileName(Image_Path), convert the local image to Base64 so it is actually embedded in the mail body.

First create a String variable base64Image:

base64Image = Convert.ToBase64String(System.IO.File.ReadAllBytes(Image_Path))

Then use this in the HTML body:
“Hi Team,” &
“Please find the process status distribution chart below:” &
“<img src='data:image/png;base64,” & base64Image & "’ " &
“style=‘width:700px; max-width:100%; height:auto; display:block;’ />” &
"
" &
“Regards,
Bot”

In Send SMTP Mail Message, make sure:

IsBodyHtml = True
Image_Path contains the complete image path

You can change 700px to 800px, 900px, etc. depending on the required size. height:auto will keep the image proportionate.

Thank for the response.
But getting the same, attached the html below


Email body:

need bigger image

@Vanitha_VS Can you try the below steps:

  1. Keep your image path in the existing variable: Image_Path = “C:\Users\Admin\Desktop\UiPath Workflows\Email Automation\StatusChart.png”
  2. Remove the current Base64 <img> code:
  3. Add an Invoke Code activity before your current SMTP activity.
  4. Set the Invoke Code language to VB.
  5. Add these arguments to Invoke Code:
Direction Name Type
In Image_Path String
In MailTo String
In MailFrom String
In SMTPServer String
In SMTPPort Int32
In SMTPUser String
In SMTPPassword String
  1. Put this code inside Invoke Code

Dim mail As New System.Net.Mail.MailMessage()

mail.From = New System.Net.Mail.MailAddress(MailFrom)
mail.To.Add(MailTo)
mail.Subject = “Process Status Distribution”

Dim htmlBody As String =
“” &
“Hi Team,” &
“Please find the process status distribution chart below:” &
“” &
"

" &
“Regards,
Bot” &
“”

Dim htmlView As System.Net.Mail.AlternateView =
System.Net.Mail.AlternateView.CreateAlternateViewFromString(
htmlBody,
Nothing,
System.Net.Mime.MediaTypeNames.Text.Html
)

Dim imageResource As New System.Net.Mail.LinkedResource(
Image_Path,
System.Net.Mime.MediaTypeNames.Image.Png
)

imageResource.ContentId = “StatusChart”
imageResource.TransferEncoding = System.Net.Mime.TransferEncoding.Base64

htmlView.LinkedResources.Add(imageResource)
mail.AlternateViews.Add(htmlView)

Dim smtp As New System.Net.Mail.SmtpClient(SMTPServer, SMTPPort)

smtp.EnableSsl = True
smtp.Credentials = New System.Net.NetworkCredential(
SMTPUser,
SMTPPassword
)

smtp.Send(mail)

imageResource.Dispose()
htmlView.Dispose()
mail.Dispose()
smtp.Dispose()

  1. For the image size, start with: width=‘700’
  2. Once this works, you do not need the Send SMTP Mail Message activity after the Invoke Code, because the Invoke Code itself sends the email

The reason their current approach fails is that data:image/png;base64,… images are not rendered consistently by email clients.

Hi @Vanitha_VS ,
Try these changes in HTML body:

Hi Team,


Please find the process status distribution chart below:


<img src=“cid:StatusChart” width="

Bot

Then:

  1. Add the image as a Linked Resource/Attachment with Content-ID = StatusChart.
  2. Increase the width and height values as needed (e.g., 800x500, 1000x600).

Thanks

@Vanitha_VS
if changing the width in the HTML still gives the same small image, I’d try embedding it as an inline image using a Content-ID/LinkedResource instead of Base64.

Some mail clients, especially Outlook, don’t handle Base64 images consistently.

Also check the original PNG dimensions. If the generated chart itself is very small, try generating it at a larger resolution first and then set the displayed width around 700–800px.