Wrox Programmer Forums
|
BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6
This is the forum to discuss the Wrox book ASP.NET 2.0 Instant Results by Imar Spaanjaars, Paul Wilton, Shawn Livermore; ISBN: 9780471749516
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 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 October 23rd, 2007, 05:44 PM
Authorized User
 
Join Date: Oct 2007
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
Default Emails not formatted correctly.

Hi Imar,

I have the emails sending out from my domain name once I finalize an order. The only issue is that the emails are not formatted correctly. I can see all of the html tags in my emails. How do we get around this. I have provided what is being sent to my inbox. Please help.

<html>
<head>
<title>Your Order Carefree Jewelry Online</title>
</head>
<body>
Dear customer,<br /><br />
Thank you for your order at Carefree Jewely Online. Your order number is
<b>6</b><br /><br />
Below you find a list of the products you have ordered. The goods will ship as
soon as we receive your payment.<br /><br />
<div>
<table cellspacing="0" rules="all" border="1" style="border-width:1px;border-style:solid;width:100%;border-collapse:collapse;">
<tr align="left" style="color:White;background-color:#ffb49f;font-family:Arial;">
<th scope="col">Title</th><th scope="col">Quantity</th><th scope="col">Price</th><th scope="col">Total</th>
</tr><tr style="color:Black;background-color:White;font-family:Arial;">
<td>this is a test</td><td align="right">1</td><td align="right">12.0000</td><td align="right">12.0000</td>
</tr><tr style="color:Black;background-color:White;font-family:Arial;">
<td>this is a test</td><td align="right">1</td><td align="right">12.0000</td><td align="right">12.0000</td>
</tr><tr style="font-family:Arial;font-weight:bold;">
<td>Totals:</td><td>&nbsp;</td><td>&nbsp;</td><td align="right">$24.00</td>
</tr>
</table>
</div>
<br /><br />
Thanks<br /><br />
The Carefree Jewelry Team
</body>
</html>


 
Old October 24th, 2007, 02:05 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Normally, with HTML mail, you would only send the mail body, so you can (should) leave this out:

<html>
<head>
<title>Your Order Carefree Jewelry Online</title>
</head>
<body>

Also, don't forget to mark the message as an HTML message when you send it.

BTW, it would be nice if you posted some follow up on answers I post here. I give you a lot of support for free and never hear anything back. I don't even know if you bought the book or just downloaded the shop's source....

Imar

---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
 
Old October 24th, 2007, 10:52 AM
Authorized User
 
Join Date: Oct 2007
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Imar,

I do have the book and I followed the enhancements for the automated emails to a T and I still am not seeing the email formatted correctly. I just took out the
<html>
<head>
<title>Your Order Carefree Jewelry Online</title>
</head>
<body> form the confirmationmessage.txt file and resent the emails. The emails are still formatted incorrectly. The only issue thing Im not clear about is where to flag this "Also, don't forget to mark the message as an HTML message when you send it."

Do you mean this piece of code.


        Dim theSubject As String = "Your order at Carefree Jewelry"
        Dim theMessage As String = My.Computer.FileSystem.ReadAllText _
          (AppConfiguration.ConfirmationMessageLocation)

        Dim mySmtpClient As New System.Net.Mail.SmtpClient
        theMessage = theMessage.Replace("##ShoppingCart##", _
                GetHtmlFromControl(myGridView))
        theMessage = theMessage.Replace("##OrderNumber##", orderId.ToString())
        mySmtpClient.Send("info@carefreejewelry.com", emailAddress, theSubject, theMessage)
      End If

 
Old October 24th, 2007, 03:32 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Odd, code like that should send, AFAIK, HTML formatted mail by default. This may work instead (taken from the Blog chapter):
Code:
Dim mySmtpClient As SmtpClient = New SmtpClient()
Dim myMessage As MailMessage = New MailMessage( _
  AppConfiguration.EmailFrom, AppConfiguration.EmailTo, subject, _
        errorMessage.ToString())
  myMessage.IsBodyHtml = True
  mySmtpClient.Send(myMessage)
  This code creates a new MailMessage and sets its IsBodyHtml property to true.

Are you sure you have a mail client that understands HTML?

Imar
---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
While typing this post, I was listening to: Paper Cup Exit by Sonic Youth (Track 8 from the album: Sonic Nurse) What's This?
 
Old October 24th, 2007, 06:51 PM
Authorized User
 
Join Date: Oct 2007
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I have tried webmail as well as Lotus Notes. I know lotus notes excepts html emails. I am trying the new code now and will post back with the results.
Thanks for the help.

 
Old October 25th, 2007, 01:15 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Well, I'd say webmail is an HTML mail capable client.... ;)

Good luck; hope it works.

Imar

---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
 
Old October 25th, 2007, 07:48 PM
Authorized User
 
Join Date: Oct 2007
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Imar,

This was it myMessage.IsBodyHtml.

This is what got it working.

thanks,
Matt

 
Old November 7th, 2007, 05:45 AM
Authorized User
 
Join Date: Oct 2007
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Could you tell me what you changed to get it working because i am stuck on the same problem

dit you just changed the code from:

Dim theSubject As String = "Your order at Carefree Jewelry"
        Dim theMessage As String = My.Computer.FileSystem.ReadAllText _
          (AppConfiguration.ConfirmationMessageLocation)

        Dim mySmtpClient As New System.Net.Mail.SmtpClient
        theMessage = theMessage.Replace("##ShoppingCart##", _
                GetHtmlFromControl(myGridView))
        theMessage = theMessage.Replace("##OrderNumber##", orderId.ToString())
        mySmtpClient.Send("info@carefreejewelry.com", emailAddress, theSubject, theMessage)
      End If

To
Dim mySmtpClient As SmtpClient = New SmtpClient()
Dim myMessage As MailMessage = New MailMessage( _
  AppConfiguration.EmailFrom, AppConfiguration.EmailTo, subject, _
        errorMessage.ToString())
  myMessage.IsBodyHtml = True
  mySmtpClient.Send(myMessage)


Or did you changed something else or more?


 
Old November 8th, 2007, 01:45 PM
Authorized User
 
Join Date: Oct 2007
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Here is the code that I used and it works perfect. Give this a try and let me know if it works for you.


Public Shared Sub SendConfirmationMessage( _
      ByVal theShoppingCart As ShoppingCart, ByVal orderId As Integer, _
      ByVal emailAddress As String)

    Try
      Dim myGridView As GridView = CreateGridView()
      myGridView.DataSource = theShoppingCart.Items
      myGridView.DataBind()

      If myGridView.Rows.Count > 0 Then
        myGridView.FooterRow.Cells(0).Text = "Totals:"
        myGridView.FooterRow.Cells(3).Text = _
                 String.Format("{0:c}", theShoppingCart.Total)

        Dim theSubject As String = "Your order at Carefree Jewelry"
        Dim theMessage As String = My.Computer.FileSystem.ReadAllText _
          (AppConfiguration.ConfirmationMessageLocation)


        Dim mySmtpClient As New System.Net.Mail.SmtpClient
        theMessage = theMessage.Replace("##ShoppingCart##", _
        GetHtmlFromControl(myGridView))
        theMessage = theMessage.Replace("##OrderNumber##", orderId.ToString())
        Dim myMessage As MailMessage = New MailMessage("info@mydomain.com", emailAddress, theSubject, theMessage)
        myMessage.IsBodyHtml = True
        mySmtpClient.Send(myMessage)

      End If

 
Old November 9th, 2007, 03:53 AM
Authorized User
 
Join Date: Oct 2007
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks man that was it, it now works really great also my cc function now works :D

I Really love these forums.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Try It Out - Adding Formatted Text p. 54 gerry789 BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 3 October 29th, 2011 11:17 AM
NOT WELL FORMATTED pallone XSLT 7 June 24th, 2008 04:45 PM
Recursive Query for Formatted Output Itech SQL Server 2005 11 June 12th, 2008 04:32 PM
Storing and Displaying Formatted Strings anubhav.kumar Classic ASP Professional 17 October 26th, 2004 10:17 PM
Formatted/HTML text pkgal79 HTML Code Clinic 2 June 18th, 2003 02:18 AM





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