easyeman
Active member
Hey all, well I posted a thread before on getting some email confirmation code working, and I finally have it working where it shows up in my email after some changes. The main problem now is I need to get the output to look right. I'll post the code and output below, and what I'd like for it to be. I've tried some code and it just hasn't turned out like I want it.
Basically I want the output to be text based but organized so it looks like a table. The purpose of the email is to confirm the items bought off a web site, and it will list quantity, item number, description, and price for each item ordered, and each item appear on a new line. So it generates sort of a table and I want it organized so it looks good and the text appears aligned. Everything else is going well but I just can't seem to get it running right, so any help would be great.
Here's the code I have (the main focus area I guess is the for-next loop where the output is being displayed)
Also, here's what the output looks like after running that:
The first two columns look nice and aligned, but after that it wants to go off, so I need to adjust the titles so they look nice and then the code where the text is all aligned. Basically I'm hoping for how it looks below:
Can anyone help me out? I'd appreciate it. I'm trying to get this done today since I have a deadline but it's not turning out quite right, but I'm just glad I have it working. Thanks!
Basically I want the output to be text based but organized so it looks like a table. The purpose of the email is to confirm the items bought off a web site, and it will list quantity, item number, description, and price for each item ordered, and each item appear on a new line. So it generates sort of a table and I want it organized so it looks good and the text appears aligned. Everything else is going well but I just can't seem to get it running right, so any help would be great.
Here's the code I have (the main focus area I guess is the for-next loop where the output is being displayed)
VB.NET:
Imports System.Net.Mail
Imports System.String
Partial Class _Default
Inherits System.Web.UI.Page
Const eServer As String = "virtmail.deltacom.net"
Const eFrom As String = "NAFECO Webstore <webstore@nafeco.com>"
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim qty As ArrayList = New ArrayList()
Dim partnum As ArrayList = New ArrayList()
Dim description As ArrayList = New ArrayList()
Dim price As ArrayList = New ArrayList()
qty.Add("1")
qty.Add("5")
qty.Add("9")
partnum.Add("5225-XL")
partnum.Add("25")
partnum.Add("1715")
description.Add("GLOVE")
description.Add("FITTING")
description.Add("NOZZLE")
price.Add("$30.00")
price.Add("$10.00")
price.Add("$250.00")
OrderConfirmationEmail("jbowling@nafeco.com", "jkbowling", "12345", qty, partnum, description, price, 250.0, 25.0, 30.0, 285.0)
End Sub
Public Sub OrderConfirmationEmail(ByVal Email As String, ByVal LoginID As String, ByVal OrderNumber As String, _
ByVal Qty As ArrayList, ByVal PartNum As ArrayList, ByVal Description As ArrayList, ByVal Price As ArrayList, ByVal subtotal As Decimal, _
ByVal Tax As Decimal, ByVal Freight As Decimal, ByVal Total As Decimal)
Try
Dim msg As New MailMessage
Dim addressFrom As New MailAddress(eFrom)
Dim addressTo As New MailAddress(Email)
Dim addressCC As New MailAddress("ehagemann@nafeco.com")
Dim Body As String
Body = Today() & Chr(10) & LoginID & ":" & Chr(10) & Chr(10) _
& "Thank you for choosing NAFECO. We have received your online order and appreciate your business." _
& Chr(10) & Chr(10) & "Your order has been assigned to customer service representative Toni McCulloch." _
& Chr(10) & "If you have any questions you can contact her at:" _
& Chr(10) & Chr(10) & "Toni McCulloch" _
& Chr(10) & "tmcculloch@nafeco.com" _
& Chr(10) & "800-628-6233 Ext.121" _
& Chr(10) & Chr(10) & "Order Number: " & OrderNumber _
& Chr(10) & Chr(10) _
& "Qty" & Chr(9) & "ProductID" & Chr(9) & "Description" & Chr(9) & Chr(9) & Chr(9) & Chr(9) & "Price" & Chr(10) _
& "----------------------------------------------------------------------" & Chr(10)
Dim i As Integer
Dim quan As String
Dim part As String
Dim desc As String
Dim pric As String
For i = 0 To PartNum.Count - 1
quan = Qty(i).ToString.PadRight(7 - Qty(i).ToString.Length, " ")
part = PartNum(i).ToString.PadRight(22 - PartNum(i).ToString.Length, " ")
desc = Description(i).ToString.PadRight(42 - Description(i).ToString.Length, " ")
pric = Price(i)
Body = Body & quan & part & desc & pric & Chr(10)
Next
'Set Message properties
With msg
.Body = Body
.From = addressFrom
.To.Add(addressTo)
.CC.Add(addressCC)
.Subject = "NAFECO Order Confirmation"
End With
'Set Email server and send mail
Dim smtp As SmtpClient = New SmtpClient
smtp.Host = eServer
smtp.Send(msg)
ErrorLabel.Text = "Email Successfully Sent"
Catch ex As Exception
ErrorLabel.Text = "Error :" & ex.ToString
End Try
End Sub
End Class
VB.NET:
12/1/2005
jkbowling:
Thank you for choosing NAFECO. We have received your online order and appreciate your business.
Your order has been assigned to customer service representative Toni McCulloch.
If you have any questions you can contact her at:
Toni McCulloch
(displays the email)
(displays number)
Order Number: 12345
Qty ProductID Description Price
----------------------------------------------------------------------
1 5225-XL GLOVE $30.00
5 25 FITTING $10.00
9 1715 NOZZLE $250.00
VB.NET:
Order Number: 12345
Qty ProductID Description Price
----------------------------------------------------------------------
1 5225-XL GLOVE $30.00
5 25 FITTING $10.00
9 1715 NOZZLE $250.00