Public Function send_order_html(ByVal orderno As String, ByVal toEmail As String, _
ByVal toName As String, ByVal ccRef As String, _
ByVal subject As String) As String
' Create instance of guixt
Dim g As New guixt
' Head of HTML for e-mail
Dim HTML As String = "
"
Try
HTML &= table_add_css() & ""
HTML &= "
Kurzübersicht über Bestellung " & orderno & "
"
' Start transaktion VA03
g.GuiSession.Enter("/nVA03")
' Enter number of order
g.GuiSession.SetField("VBAK-VBELN", orderno)
g.GuiSession.Enter()
' Get some data of order
HTML &= "Nettowert: " & g.GuiSession.GetField("VBAK-NETWR") & " "
HTML &= g.GuiSession.GetField("VBAK-WAERK") & "
"
HTML &= "Auftraggeber: " & g.GuiSession.GetField("KUAGV-TXTPA") & "
"
HTML &= "Warenempfänger : " & g.GuiSession.GetField("KUWEV-KUNNR") & "
"
HTML &= "Bestellnumme: " & g.GuiSession.GetField("VBKD-BSTKD") & "
"
HTML &= "Bestelldatum: " & g.GuiSession.GetField("VBKD-BSTDK") & "
"
' Define table for ReadTable()
Dim dt As DataTable = New DataTable("Orders")
dt.Columns.Add("POSNR")
dt.Columns.Add("MABNR")
dt.Columns.Add("KWMENG")
dt.Columns.Add("VRKME")
dt.Columns.Add("ARKTX")
HTML &= "
Positionen:
"
' Read table with guinet.dll (SAP GUI Scripting)
g.GuiSession.ReadTable(dt)
HTML &= " Pos | " _
& "Mat.No. | Menge | Einheit | Beschreibung |
"
HTML &= ""
g.GuiSession.Enter("/3")
' Format table with HTML
For i = 0 To dt.Rows.Count - 1
HTML &= ""
HTML &= "" & dt.Rows(i)(0) & " | "
HTML &= "" & dt.Rows(i)(1) & " | "
HTML &= "" & dt.Rows(i)(2) & " | "
HTML &= "" & dt.Rows(i)(3) & " | "
HTML &= "" & dt.Rows(i)(4) & " | "
HTML &= "
"
Next
HTML &= "
"
Catch ex As Exception
Return ex.Message
End Try
Dim e As New email
' Send e-mail with SMTP
e.send_order(toEmail, toName, ccRef, subject, HTML)
Return HTML
End Function