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 21st, 2009, 08:16 PM
Friend of Wrox
 
Join Date: Sep 2009
Posts: 165
Thanks: 5
Thanked 6 Times in 6 Posts
Arrow emailing in webshop............

Hello Sir,
Well I am here after a great time. I was trying myself to complete the application but finally I got stuck in emailing.
Well I am able to send mails to both (admin and customer).
But problem is that I'm having problem in showing exact item details.
I am sending email on the click of Finalize Order button in checkout.aspx page. Problem is that I am not able to access the shopping cart placeholder. How I can use it.
I am using the following method of sending email......

Code:
Protected Sub btnFinalize_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnFinalize.Click
        If Page.IsValid And Profile.ProfileCompleted = True Then

            Try
                Dim orderedItems As List(Of OrderedProduct) = ShopManager.ShoppingCart.Items
                Dim orderAmount As Decimal =   ShopManager.ShoppingCart.Total
Dim shoppingCart As ShoppingCart = ShopManager.ShoppingCart()
                Dim theCustomer As Customer = _
                  New Customer(CType(Membership.GetUser().ProviderUserKey, Guid), _
                  Profile.FirstName, Profile.LastName, Profile.Address.Street, _
                  Profile.Address.ZipCode, Profile.Address.City, Profile.Address.Country)
                Dim orderId As Integer = ShopManager.FinalizeOrder(theCustomer)

                Dim fileName As String = Server.MapPath("~/App_Data/OrderForm.txt")
               
                Dim mailBody As String = System.IO.File.ReadAllText(fileName)
                mailBody = mailBody.Replace("##First_Name##", Profile.FirstName)
               other place hoders goes here...........
 mailBody = mailBody.Replace("##OrderNumber##", orderId) 'Working    
            mailBody = mailBody.Replace("##OrderAmount##", orderAmount) 'working    
            'mailBody = mailBody.Replace("##ShoppingCart##", HttpContext.Current.Session   ("ShoppingCart")) ' not working
                Dim myMessage As New MailMessage()
                myMessage.Subject = "Order Request From Web Site"
                myMessage.Body = mailBody

                myMessage.From = New MailAddress("[email protected]", "Sender Name")
                myMessage.To.Add(New MailAddress("[email protected]", "Receiver Name"))

                Dim mySmtpClient As New SmtpClient()
                Try
                    mySmtpClient.EnableSsl = True
                    mySmtpClient.Send(myMessage)
                
                Catch ex As Exception
                    lblFailure.Visible = True
                    btnFinalize.Visible = False
                End Try

                'lblMessage.Visible = True
                'FormTable.Visible = False
                Response.Redirect("ThankYou.aspx?OrderNumber=" & _
                                        orderId.ToString() & "&Total=" & orderAmount.ToString("c"))
                'Helpers.SendConfirmationMessage(ShopManager.ShoppingCart, orderId, Membership.GetUser().Email)
            Catch ex As Exception
                lblFailure.Visible = True
                btnFinalize.Visible = False
            End Try
        Else
            Response.Redirect("~/UserDetails.aspx")

        End If
    End Sub
So please tell me how I can access property for ShoppingCart placeholder
Any suggestion is most required and this is the only thing that is left
Thank you..........

Last edited by jack_hilary; October 21st, 2009 at 08:22 PM..
 
Old October 22nd, 2009, 03:10 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

My oh my, you haven't learned a lot from our previous discussions, have you? Why is it that if you want help, you're not helping us by prodiing the information we need to solve your problem?

For example, define "not working". Do you get an error? If so, which one? What happens when you step through the code line by line? What do you see? How did you setup the application? When are you executing this code? What do you see when you look at the session object in the debugger? When you look at the template file, what data does it contain? Are you sure there is stuff in the shopping cart?

Etc etc etc and so on and so forth. Pfffff
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old October 22nd, 2009, 04:36 PM
Friend of Wrox
 
Join Date: Sep 2009
Posts: 165
Thanks: 5
Thanked 6 Times in 6 Posts
Arrow

problem is solved.............................
Thank you and keep smiling





Similar Threads
Thread Thread Starter Forum Replies Last Post
Emailing from Excel danielharris Excel VBA 0 January 11th, 2006 06:39 PM
dynamic emailing ips2004 JSP Basics 1 December 8th, 2004 01:57 PM
HTML Emailing [email protected] BOOK: Expert One-on-One Access Application Development 1 November 24th, 2004 06:32 PM
Auto-Emailing hafizism Excel VBA 1 October 29th, 2004 09:43 AM
emailing forms.. kyootepuffy Classic ASP Databases 3 August 26th, 2003 03:54 PM





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