Reputation: 445
I have to embeded an image in an email
<img src="....." style="float:right;height;400px;"/>
I create and alternate view this way
try{
System.Net.Mime.ContentType mimeType = new System.Net.Mime.ContentType(System.Net.Mime.MediaTypeNames.Text.Html);
AlternateView avHTMLImage = AlternateView.CreateAlternateViewFromString(msgMail.Mensaje, mimeType);
LinkedResource lrHTMLImage;
System.IO.MemoryStream img = new System.IO.MemoryStream(Imagen.Image2Bytes(ie.img));
lrHTMLImage = new LinkedResource(img, System.Net.Mime.MediaTypeNames.Image.Jpeg);
lrHTMLImage.ContentId = ie.nombreImg;
avHTMLImage.LinkedResources.Add(lrHTMLImage);
avHTMLImage.ContentId = ie.nombreImg;
this.mail.AlternateViews.Add(avHTMLImage);
}
But it is attaching and embedding the image without the settings of float neither height I'm telling it
Upvotes: 1
Views: 769
Reputation: 669
try and avoid using css where possible in an email. you may find that it's something to do with perhaps the loading order of the css? Some basics to adhere to just in case http://kb.mailchimp.com/campaigns/ways-to-build/css-in-html-email. Put the styling in, the old way eg...
<img src="....." align="right" width="..%" />
and then set the width, making sure that the image is proportionally correct to the width. Setting heights in an email is tricky as clients like outlook and online email viewed in IE will ignore and use the default image size.
FYI also use
display:inline-block
on your images to avoide unwanted margins in gmail
Upvotes: 5