Wrox Programmer Forums
|
ASP.NET 4 General Discussion For ASP.NET 4 discussions not relating to a specific Wrox book
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 4 General Discussion section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 11th, 2011, 04:05 PM
Authorized User
 
Join Date: Jan 2011
Posts: 89
Thanks: 1
Thanked 0 Times in 0 Posts
Default Sending Emails with images

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?
 
Old November 11th, 2011, 04:30 PM
Authorized User
 
Join Date: Jan 2011
Posts: 89
Thanks: 1
Thanked 0 Times in 0 Posts
Unhappy

UPDATE:

I'm using outlook connector with a live account and found that adding the email address to the safe senders list allowed the HTML formatting, but this is a potential problem for users - I'm guessing the official way to ensure HTML and plain text goes to the right recipients is by using AlternateViews. This method however removed my line spacing/layout from the text file I store my email content in.
 
Old December 3rd, 2011, 04:46 AM
Registered User
 
Join Date: Nov 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Able to do using in build mail message class and call .attachmethod, then do proper coding as per your requirement and got your out put.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Sending Emails with port 465 Cooler BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 3 March 1st, 2011 04:36 PM
Sending Multiple Emails Brendan Bartley Access 2 January 25th, 2009 01:49 AM
Chapter 9 - Sending eMails havardoj BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 3 January 24th, 2009 07:15 PM
Sending automatic emails maitias C# 2005 3 March 3rd, 2006 09:51 PM
sending emails from vb.Net elan22 General .NET 5 May 27th, 2004 08:53 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.