Adding an image to the html body of an email

Asked

Viewed 430 times

1

I’m trying to do an automated sending scheme using c# . NET, my problem is time to add an image in the body of the email, in which the image does not appear.

This icon appears in place of the image I’m trying to incerir: inserir a descrição da imagem aqui

Html of the email body:

<div>
    <img src = "../ModelOdyss/Images/image.png">
</div>

The image I’m trying to insert is inside the "Images" folder and the html is inside the "Controllerodyss" folder".

inserir a descrição da imagem aqui

Where am I going wrong ?

1 answer

3


You have to put the absolute path of the image. Type:

src="http://meusite.com/ModelOdyss/Images/image.png"

Where in meusite.com you will place the domain of your website.

The email client will not find the relative path ../ModelOdyss/Images/image.png and will display instead this broken image icon.

Read on in this topic to understand a little about relative and absolute paths.

  • I just tried the change and it still doesn’t work. sera is because instead of "meusite.com" I’m using localhost ?

  • 1

    Exactly... the email client will fetch the image on the internet, there is no way to search on your computer... unless your local server is configured to be visible on the internet..

  • And yet you would have to put the ip or a domain that points to your server. But that’s kind of a tricky thing to do. You will only work with local server, will not go up for a hosting?

  • In the future, yes. However, I would like to know if there is any way to attach this image using localhost.

  • 1

    Unfortunately there is no way. The image must be on an internet server.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.