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 November 25th, 2008, 01:49 PM
Authorized User
 
Join Date: Oct 2007
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Imar,

I use MS Outlook for FromMail part.

I don't know how to use it as following quotes from you hyperlink reference. And where do I put IsBodyHtml?

Thanks,
HD

=========== Quoted from your advuice's hyperlink =========

Public Class MailMessage _
    Implements IDisposable
Dim instance As MailMessage


 
Old November 25th, 2008, 02:20 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Heuh? Don't know where to put it? It's all in my sample code I posted, isn't it?

Try this:

1. Choose File | New Web Site.

2. Switch Default.aspx to Design View and double click anywhere on the page to set up a Load handler.

3. Inside the handler add this code:
Code:
Dim message As MailMessage = New MailMessage( _
    "[email protected]", _
    "[email protected]", _
    "Subject.", _
    "<h1>Hello World</h1><span style=""color:red;"">This is red</span>")
  message.IsBodyHtml = True
  Dim mySmtpClient As New SmtpClient
  mySmtpClient.Send(message)
  Don't forget to fix the e-mail addresses.

4. Add this to the top of the file:

    Imports System.Net.Mail

5. Add your mail server to the web.config file

6. Hit F5 to request the page in the browser.

The mail gets sent, and should be presented as HTML.

If not, check your client settings and make sure the mail is not marked as junk in Outlook as that sometimes shows the raw HTML.

Hope this helps,

Imar


---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of Beginning ASP.NET 3.5 : in C# and VB, ASP.NET 2.0 Instant Results and Dreamweaver MX 2004
Want to be my colleague? Then check out this post.
 
Old November 25th, 2008, 04:09 PM
Authorized User
 
Join Date: Oct 2007
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Dear Imar,

I really appreciated that you were so kind in this novice matter.
I have gotten the right solution. I included my codes for user's reference.

Thanks,
HD

    Public Shared Sub SendConfirmationMessage( _
        ByVal theShoppingCart As ShoppingCart, ByVal orderId As Integer, _
        ByVal userName As String, 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 theSender As String = "[email protected]"
                Dim theSubject As String = "Your order at Sports Camps"
                Dim theMessage As String = My.Computer.FileSystem.ReadAllText _
                  (AppConfiguration.ConfirmationMessageLocation)

                theMessage = theMessage.Replace("##ShoppingCart##", GetHtmlFromControl(myGridView))
                theMessage = theMessage.Replace("##OrderNumber##", orderId.ToString())

                Dim message As MailMessage = New MailMessagetheSender, emailAddress, theSubject, theMessage)
                message.IsBodyHtml = True
                Dim mySmtpClient As New System.Net.Mail.SmtpClient
                mySmtpClient.Send(message)

            End If
        Catch ex As Exception
        End Try
    End Sub
End Class

 
Old November 25th, 2008, 04:11 PM
Authorized User
 
Join Date: Oct 2007
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Correction:

Dim message As MailMessage = New MailMessage(theSender, emailAddress, theSubject, theMessage)


 
Old November 26th, 2008, 05:31 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Great. Glad it's all working now and thanks for the update.

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of Beginning ASP.NET 3.5 : in C# and VB, ASP.NET 2.0 Instant Results and Dreamweaver MX 2004
While typing this post, I was listening to: Natural blues by Moby (Track 8 from the album: Play) What's This?

Last edited by Imar; June 29th, 2009 at 06:42 PM..





Similar Threads
Thread Thread Starter Forum Replies Last Post
Urgent - Send mail with plain view and html view ashish.dadhwal ASP.NET 2.0 Professional 0 November 27th, 2008 01:49 AM
Show Tree Format data rajasarkar ASP.NET 1.0 and 1.1 Professional 0 July 5th, 2006 02:59 AM
plain vs HTML format juergreh Beginning PHP 2 April 19th, 2005 08:42 AM





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