Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #11 (permalink)  
Old November 25th, 2008, 01:49 PM
Authorized User
 
Join Date: Oct 2007
Location: , , .
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


  #12 (permalink)  
Old November 25th, 2008, 02:20 PM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 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( _
    "you@yourprovider.com", _
    "you@yourprovider.com", _
    "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.
  #13 (permalink)  
Old November 25th, 2008, 04:09 PM
Authorized User
 
Join Date: Oct 2007
Location: , , .
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 = "myname@mymail.com"
                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

  #14 (permalink)  
Old November 25th, 2008, 04:11 PM
Authorized User
 
Join Date: Oct 2007
Location: , , .
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Correction:

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


  #15 (permalink)  
Old November 26th, 2008, 05:31 PM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 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..
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 10:15 PM.


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