Link to home
Start Free TrialLog in
Avatar of r3nder
r3nderFlag for United States of America

asked on

set image source in html

I am trying to set a dynamic image source in an email body how do I do that?
 message.Body += "<p align = center><img src = '\\\\192.168.1.254\\Common\\Software\\Maps\\' + 'Map' + today + '.png' ></p>";

Open in new window

Avatar of FarWest
FarWest

do you want every one receive the email to load it from this location when it is viewed?
or bind it with the email?
images that is part of the email should be first saved as attachments, give them a unique id, and use CID tag to refer to them
Avatar of r3nder

ASKER

bind it - can you tell me how to do that?
ASKER CERTIFIED SOLUTION
Avatar of FarWest
FarWest

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
Of course none of it makes a difference if the user has images blocked, does not accept an HTML version of email, or the user has filters that only allows images from whitelisted senders.

Cd&
@COBOLdinosaur The show Image security is different when it is "External Content" or "Attachments"
beside when embedding images with message you don't have to host those images or make them available to public or even share a folder in your computer for internal emails,

BTW I like your nickname and it looks like you are over 50 like me, and "IDENTIFICATION DIVISION" persist in your brain just like mine ;)
Avatar of r3nder

ASKER

@all - I am 50 :D but thank you all for your advice - here is how I did it - just as an fya the emails go to internal customers

            string contentID = "i" + Guid.NewGuid().ToString() + ".png@EMBED";
            Attachment inline = new Attachment(@"\\192.168.1.254\Common\Software\Maps\" + "Map" + today + ".png");
            inline.ContentDisposition.Inline = true;
            inline.ContentDisposition.DispositionType = DispositionTypeNames.Inline;
            inline.ContentId = contentID;
            inline.ContentType.MediaType = "image/png";
            inline.ContentType.Name = Path.GetFileName(@"\\192.168.1.254\Common\Software\Maps\" + "Map" + today + ".png");
            message.Attachments.Add(inline);

Open in new window

Avatar of r3nder

ASKER

fryezz Thank you for telling me how it was done
you are welcome
and glad I could help
Not indicating it was internal leaves out a pretty key piece of information that changes the nature of the question.

As for 50... that makes you a kid.  I was learning to code in assembler about the time you were being born.  Moving to COBOL was a quantum technology leap when Grace Hopper finally got a stable version for the world to use.

Cd&
@COBOLdinosaur I wish you a very happy and healthful time, and to enjoy your over 100  birthdays
and very glad to have a chance to have dialogue with you.
Avatar of r3nder

ASKER

@COBOLdinosaur - at the coding level its down to semantics. The question then becomes "What would  you prefer" - I could have captured  the image then uploaded via ftp to our website, but I felt that would be to much of a maintenance burden on the network admin (me as well) to constantly clear out those files as they built up. Now its imbedded and I don't have to give it a second thought :D