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..........