Hi all,
I'm pulling my hair out over an issue I'm having while trying to add images to my emails (sent from aspx pages) with header and footer images.
I tried formatting the entire email in HTML and setting:
Code:
myMessage.IsBodyHtml = True
- this was flaky and stopped working with my outlook which resulted in ugly HTML literal text in the email.
I tried using AlternateView:
Code:
Dim TextView As AlternateView = AlternateView.CreateAlternateViewFromString(mailBody, Nothing, "text/plain")
Dim htmlView As AlternateView = AlternateView.CreateAlternateViewFromString(mailBody + "<image src=cid:myImage>", Nothing, "text/html")
Dim myResource As New LinkedResource(HttpContext.Current.Request.MapPath("") + "/EmailImages/myImage.jpg")
myResource.ContentId = "Image"
htmlView.LinkedResources.Add(myResource)
myMessage.AlternateViews.Add(TextView)
myMessage.AlternateViews.Add(htmlView)
This didnt work, instead it dropped the text formatting and displayed everything in a paragraph block with no spaces etc.
I tried using some image links in the email body itself, e.g.:
<http://www.mydomain.com/images/banner1.jpg>
<img src="http://www.mydomain.com/images/footer.jpg"/>
These dont render as images, my outlook settings are set to show HTML emails and the option to render emails as plain text is not selected.
Can anyone help or give any examples of how they have done this?