Link to home
Start Free TrialLog in
Avatar of Murray Brown
Murray BrownFlag for United Kingdom of Great Britain and Northern Ireland

asked on

ASP.net Include image in body of email (System.Net.Mail)

Hi
I am trying to include an image from the Resources folder of my ASP.net website in the html body of my email.
The first line below, which gets an image from another site worked, but the second line, where I try to get the images from my site resources didn't

            oHBody = oHBody & "<img src=""http://www.beansoftware.com/Images/Logo.jpg"" alt=""Logo"" "
           
            Dim oImagePath As String = Server.MapPath("~/Resources/Q.jpg")
            oHBody = oHBody & "<img src=""" & oImagePath & """ alt=""Logo"" "
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

surely because your oImagePath contains a local (c:\intepub\yourfile.ext) reference which is not valid from the client view.

Give a try to
Dim oImagePath As String = HostingEnvironment.MapPath("~/Resources/Q.jpg")

Open in new window


more details at http://codeconsults.com/map-path/
Avatar of Murray Brown

ASKER

I get Error      'HostingEnvironment' is not declared.'
missing the namespace probably: System.Web.Hosting.HostingEnvironment.MapPath
Hi. Sorry I figured that part out. This is the code I use to build the html but iy doesn't work
            Dim oImagePath As String = System.Web.Hosting.HostingEnvironment.MapPath("~/Resources/Q.jpg")
            oHBody = oHBody & "<img src=""" & oImagePath & """ alt=""Logo"" "
more details please?

what is the value of oImagePath?
ASKER CERTIFIED SOLUTION
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks very much for the help