?
Solved

set image source in html

Posted on 2015-01-15
11
Medium Priority
?
108 Views
Last Modified: 2015-01-15
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

0
Comment
Question by:r3nder
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
  • 2
11 Comments
 
LVL 12

Expert Comment

by:FarWest
ID: 40551400
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
0
 
LVL 6

Author Comment

by:r3nder
ID: 40551407
bind it - can you tell me how to do that?
0
 
LVL 12

Accepted Solution

by:
FarWest earned 2000 total points
ID: 40551432
this is from  a code i currently use

string imageCid = "i" + Guid.NewGuid().ToString() + ".jpg@EMBED";
string imgPath="your file full path"
outLookMailMessage.HTMLBody = htmlTemplate.Replace("cid:i##imageid#.jpg@embed", string.Format("cid:{0}", imageCid));
Outlook.Attachment attachment1 = outLookMailMessage.Attachments.Add(imgPath, Outlook.OlAttachmentType.olEmbeddeditem, null, "");
attachment1.PropertyAccessor.SetProperty("http://schemas.microsoft.com/mapi/proptag/0x3712001E", imageCid);

Open in new window

here the code is using a string that has html template and replace image source tag
0
WordPress Tutorial 1: Installation & Setup

WordPress is a very popular option for running your web site and can be used to get your content online quickly for the world to see. This guide will walk you through installing the WordPress server software and the initial setup process.

 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 40551525
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&
0
 
LVL 12

Expert Comment

by:FarWest
ID: 40551568
@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 ;)
0
 
LVL 6

Author Comment

by:r3nder
ID: 40551598
@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

0
 
LVL 6

Author Closing Comment

by:r3nder
ID: 40551604
fryezz Thank you for telling me how it was done
0
 
LVL 12

Expert Comment

by:FarWest
ID: 40551610
you are welcome
and glad I could help
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 40551730
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&
0
 
LVL 12

Expert Comment

by:FarWest
ID: 40551773
@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.
0
 
LVL 6

Author Comment

by:r3nder
ID: 40551833
@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
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
Originally, this post was published on Monitis Blog, you can check it here . Websites are getting bigger and more complicated by the day. Video, images and custom fonts are all great for showcasing your product or service. But the price to pay in…
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question