购物车列表查看电子邮件 [英] Shopping Cart List View Email

查看:74
本文介绍了购物车列表查看电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我有一个问题,试图获取使用列表框显示的购物车中的商品也会显示在电子邮件中在订单处理后发送,一个发送给管理员,一个收据发送给客户。



Hi All,

im having an issue trying to get the items in the shopping cart which is displayed using a listbox to also be displayed in the email which gets sent after the order is processed, one to admin and a receipt to the customer.

Protected Sub btnProOrd_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnProOrd.Click
    Dim sName As String, sEmail As String, sAddress As String, sSub As String
    Dim sPCode As String, sState As String, sOrder As String, sPayment As String


    sName = Trim(CusName.Text)
    sEmail = Trim(CusEmail.Text)
    sAddress = Trim(CusAddr.Text)
    sSub = Trim(CusSub.Text)
    sPCode = Trim(CusPCode.Text)
    sState = Trim(CusState.Text)
    sPayment = Trim(lstCardType.Text)
    sOrder = Trim(lstCart.Items.ToString)



    Dim MyMail As New MailMessage()
    MyMail.From = New MailAddress(CusEmail.Text)
    MyMail.To.Add(txtTo.Text)
    MyMail.To.Add(CusEmail.Text)

    MyMail.Body = "New Order Recieved" + vbNewLine + "Customer Name" + " " + sName + vbNewLine + "Customer Address" + vbNewLine + sAddress + vbNewLine + sSub + " " + sPCode + " " + sState + vbNewLine + vbNewLine + "Payment Method" + " " + sPayment + vbNewLine + "Customer Order" + vbNewLine + sOrder


    Dim SmtpMail As New SmtpClient
    SmtpMail.Send(MyMail)

    MsgBox("Your order has been submitted for processing. A copy has been sent to your email as well.")





任何帮助表示赞赏。

谢谢



Any help is appreciated.
Thanks

推荐答案

而不是你的行...



Instead of your line...

sOrder = Trim(lstCart.Items.ToString)





使用循环并循环浏览项目





use a loop and loop through the items

For i = 0 to lstCart.Items.count
 sOrder = sOrder & lstCart.Items(i)
Next i







对不起,

请用+符号替换&符号




Sorry,
Please replace the & symbol with + symbol


你好会员9608236,



我只能假设我给你的代码有错误。

然后第二次看它,是的有!



因为lstCart.Items集合是基于ZERO并且从ZERO开始而不是一个,在代码中阻止我在变量''i'的值上方发布的超过列表中的项目数。



S o您可以将代码更改为此,如果您仍然收到错误,则错误发生在其他地方而不是我发布的代码块中。在这种情况下,您将不得不更详细地发布您的错误详细信息。



更改此代码...

Hello Member 9608236,

I can only assume there is an error in the code I gave you.
And upon a second look at it, yes there is!

As the lstCart.Items collection is ZERO based and starts at ZERO and NOT ONE, in the code block i posted above the value of the variable ''i'' is exceeding the number of items in the list.

So you can change your code to this and if you STILL get an error then the error is elsewhere and NOT in the code block I posted. In which case you will have to post your error details in more detail.

CHANGE CODE TO THIS...
For i = 0 to lstCart.Items.count - 1
 sOrder = sOrder & lstCart.Items(i)
Next i





我改变了第一行...



I have changed the first line...

For i = 0 to lstCart.Items.Count











to

For i = 0 to lstCart.Items.Count -1


这篇关于购物车列表查看电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆