i have a problem when send email i want the data to be grouped but the email is sent individually for each data
here is the result email
Print Order
Ordered From: MostlyArt.com
Order Id: 203
Ordered Date: 4/28/2008
Customer Notes:
Bill To:
A & F Gallery
32 N. Huron St.
Ypsilanti, MI 48197
United States
Ship To:
Shaw Cheektowaga
3806 Union Rd #252
Cheektowaga, NY 14225-4248
United States
Nicholas De Stael, Noon Landscape
Pub: EUR
Number: EUR/1400-13241
Qty: 1
Price: $32.00
Subtotal: $32.00
Shipping: $10
Sales Tax: $0
Discount: $0
Total: $42.00
i want the result email grouped by Ship To:
Print Order
Ordered From: MostlyArt.com
Order Id: 203
Ordered Date: 4/28/2008
Customer Notes:
Bill To:
A & F Gallery
32 N. Huron St.
Ypsilanti, MI 48197
United States
Ship To:
Shaw Cheektowaga
3806 Union Rd #252
Cheektowaga, NY 14225-4248
United States
Nicholas De Stael, Noon Landscape
Pub: EUR
Number: EUR/1400-13241
Qty: 1
Price: $32.00
F Senatore, Setimo Impacto (Abstract)
Pub: EUR
Number: EUR/1505-15073
Qty: 1
Price: $38.00
Tc Chiu, Chef III
Pub: APG
Number: APG/136-22231
Qty: 1
Price: $14.50
Subtotal:
$84.50
Shipping: $10
Sales Tax: $0
Discount: $0
Total:
$94.50
all above in bold are the data i want in this format here is the code
Dim conn As SqlConnection
Dim cmd As SqlCommand
Dim cmdString As String = "usp_order_OrderPrints"
Dim theError As String
theError =
""
conn = New SqlConnection(ConfigurationManager.ConnectionStrin gs("customerdbConnectionString").ConnectionString) cmd = New SqlCommand(cmdString, conn)
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.Add("@steptype", SqlDbType.VarChar)
cmd.Parameters(
"@steptype").Value = "1"
conn.Open()
Dim myReader As SqlDataReader
myReader = cmd.ExecuteReader(CommandBehavior.CloseConnection)
Dim EmailTo, EmailSubject, EmailBody, EmailFrom, MAOrderNum, printCode, PosterName, dropshipaddresstype, specialInstructions, ArtistName, Publisher, Price, CustomerName, PrintCodeInStock As String
Dim Bill_ContactName, Bill_Address, Bill_City, Bill_Province, Bill_PostalCode, Bill_Country, Ship_ContactName, Ship_Address, Ship_City, Ship_Province, Ship_PostalCode, Ship_Country As StringDim orderId, qty, RowsReturned, t1Bill_Amt, temp_Amnt As Int32
Dim t1Ship_ContactName, t1Bill_ContactName, t1Bill_Address, t1Ship_Address As String
RowsReturned = 0
While myReader.Read()
Trace.Write("send to:" & myReader.GetString(0))
' send email to supplier
EmailTo = myReader.GetString(0)
orderId = myReader.GetInt32(1)
MAOrderNum = myReader.GetString(2)
printCode = myReader.GetString(3)
PosterName = myReader.GetString(4)
qty = myReader.GetInt32(5)
dropshipaddresstype = myReader.GetString(6)
specialInstructions = myReader.GetString(7)
Bill_ContactName = myReader.GetString(8)
Bill_Address = myReader.GetString(9)
Bill_City = myReader.GetString(10)
Bill_Province = myReader.GetString(11)
Bill_PostalCode = myReader.GetString(12)
Bill_Country = myReader.GetString(13)
Ship_ContactName = myReader.GetString(14)
Ship_Address = myReader.GetString(15)
Ship_City = myReader.GetString(16)
Ship_Province = myReader.GetString(17)
Ship_PostalCode = myReader.GetString(18)
Ship_Country = myReader.GetString(19)
ArtistName = myReader.GetString(20)
Publisher = myReader.GetString(21)
Price = myReader.GetDecimal(22)
CustomerName = myReader.GetString(23)
PrintCodeInStock = myReader.GetString(24)
'' SEND ALL TO JASON FOR NOW
'If EmailTo = "" Then
'EmailTo = "
[email protected],
[email protected],
[email protected]"
EmailTo =
"
[email protected]"
'End If
EmailFrom =
"
[email protected]"
'EmailSubject = "Print Order - Id # " & orderId
EmailSubject =
"Order"EmailBody = "Print Order" & vbCrLf & vbCrLf
If Trim(PrintCodeInStock) <> "" ThenEmailBody += "This is an item that is in stock" & vbCrLf
End If
EmailBody += "Ordered From: MostlyArt.com" & vbCrLf
EmailBody +=
"Order Id: " & orderId & vbCrLf
'EmailBody += "MostlyArt Order #: " & MAOrderNum & vbCrLf & vbCrLf
EmailBody += "Ordered Date: " & FormatDateTime(Now(), DateFormat.ShortDate) & vbCrLf & vbCrLf
'EmailBody += "Special Instruction: " & specialInstructions & vbCrLf & vbCrLf
EmailBody += "Customer Notes: " & vbCrLf & vbCrLf
EmailBody += "Bill To: " & vbCrLf
EmailBody += CustomerName & vbCrLf
'EmailBody += Bill_ContactName & vbCrLf
EmailBody += Bill_Address & vbCrLf
EmailBody += Bill_City & ", " & Bill_Province & " " & Bill_PostalCode & vbCrLf
EmailBody += Bill_Country & vbCrLf & vbCrLf
EmailBody += "Ship To: " & vbCrLf
EmailBody += Ship_ContactName & vbCrLf
EmailBody += Ship_Address & vbCrLf
EmailBody += Ship_City & ", " & Ship_Province & " " & Ship_PostalCode & vbCrLf
EmailBody += Ship_Country & vbCrLf & vbCrLf
EmailBody += ArtistName & ", " & PosterName & vbCrLf
EmailBody +=
"Pub: " & Publisher & vbCrLfEmailBody += "Number: " & printCode & vbCrLf
EmailBody +=
"Qty: " & qty & vbCrLfEmailBody += "Price: " & FormatCurrency(Price, 2) & vbCrLf & vbCrLf
EmailBody += "Subtotal: $" & Price * qty & vbCrLf
EmailBody +=
"Shipping: $" & ShippingCharge & vbCrLfEmailBody += "Sales Tax: $0" & vbCrLf
EmailBody +=
"Discount: $0" & vbCrLfEmailBody += "Total: $" & Price * qty + ShippingCharge & vbCrLf
Dim Msg As System.Net.Mail.MailMessage = New System.Net.Mail.MailMessage()Msg.From = New System.Net.Mail.MailAddress(EmailFrom)
Msg.To.Add(EmailTo)
Msg.Subject = EmailSubject
Msg.Body = EmailBody
Msg.IsBodyHtml =
False
'Dim basicAuthenticationInfo As New System.Net.NetworkCredential("request@ruralphilant hropy.ca", "foundation")Dim MailObj As New System.Net.Mail.SmtpClient("localhost")
'MailObj.Credentials = basicAuthenticationInfo
MailObj.Send(Msg)
RowsReturned += 1
End While
If RowsReturned = 0 Then
theError =
"There are no orders to send"
End If
myReader.Close()