%
Sub FormatMail (rsOrder, rsitems, merchant, customer)
'*************** Formats mail to Merchant and Customer
' Version 6.50 July 6, 2005
' Used only if VP-ASP Option Package is not installed
' Option package uses templates
'******************************************************************
dim ydecimalpoint
ydecimalpoint=getconfig("xdecimalpoint")
Body=""
Dim Body
Dim body1
dim body2
Dim CR
Dim description
Dim FullName, AddressName, CityName, StateName, CountryName, PostalName, Nameb, Addressb, Cityb, Stateb, Countryb, Companyb, Postalb
Dim Companyname
Dim DeliveryAddress, DeliveryArray
dim downloadlink
CR = GetMailCR
SetSess ("EmailFormat"),"Text"
body1 = getlang("langmailmerchant") & cr
body2 = getlang("langmailcustomer") & cr
body = getlang("langmailordernumber") & rsorder("orderid") & cr &_
getlang("langmailorderamount") & shopformatcurrency(rsorder("orderamount"),ydecimalpoint) & cr &_
getlang("langmailshippingcost") & shopformatcurrency(rsorder("oshipcost"),ydecimalpoint) & cr &_
getlang("langmailshippingmethod") & rsorder("oshipmethodtype") & cr &_
getlang("langmailtax") & shopformatcurrency(rsorder("otax"),ydecimalpoint) & cr
'VP-ASP 6.50 - add handling for Canadian PST
if NOT isnull(rsorder("opst")) then
body = body & "PST" & shopformatcurrency(rsorder("opst"),ydecimalpoint) & cr
end if
'VP-ASP 6.50 - show handling fee
getlang("langproducthandling") & shopformatcurrency(rsorder("ohandling"),ydecimalpoint) & cr
if rsorder("odiscount")>0 then
body=body & getlang("langmaildiscount") & shopformatcurrency(rsorder("odiscount"),ydecimalpoint) & cr
end if
body = body & cr &_
getlang("langmailpayment") & rsorder("ocardtype") & cr &_
getlang("langmaildate") & shopdateformat(rsorder("odate"),getconfig("xdateformat")) & cr &_
getlang("langmailphone") & rsorder("ophone") & cr &_
getlang("langmailemail") & rsorder("oemail") & cr & cr &_
getlang("langmailshipto") & cr & cr
if not isnull(rsorder("oshipname")) then
fullname = rsorder("oshipname")
else
fullname = rsorder("ofirstname") & " " & rsorder("olastname")
end if
if not isnull(rsorder("oshipaddress")) then
addressname = rsorder("oshipaddress")
else
addressname = rsorder("oaddress")
end if
if Not isNULL(rsorder("oshiptown")) then
CityName = rsOrder("oshiptown")
else
CityName = rsOrder("ocity")
end if
if Not isNULL(rsorder("oshipstate")) then
StateName = rsOrder("oshipstate")
else
StateName = rsOrder("ostate")
end if
if Not isNULL(rsorder("oshipzip")) then
PostalName = rsOrder("oshipzip")
else
PostalName = rsOrder("opostcode")
end if
if Not isNULL(rsorder("oshipcountry")) then
CountryName = rsOrder("oshipcountry")
else
CountryName = rsOrder("ocountry")
end if
Body = Body & FullName & CR
if Not isNULL(rsorder("oshipcompany")) then
Body = Body & rsOrder("oshipcompany") & CR
else
IF Not isNULL(rsorder("ocompany")) then
Body = Body & rsOrder("ocompany") & CR
End If
end if
Body = Body & AddressName & CR &_
"" & CityName & ", " & StateName & " " & PostalName & CR &_
"" & CountryName & CR & CR &_
getlang("langMailCustomerIs") & CR & CR
FullName = rsOrder("ofirstname") & " " & rsOrder("olastname")
AddressName = rsOrder("oaddress")
CityName = rsOrder("ocity")
StateName = rsOrder("ostate")
PostalName = rsOrder("opostcode")
CountryName = rsOrder("ocountry")
Companyname=""
IF Not isNULL(rsorder("ocompany")) then
Companyname=("ocompany")
End If
Body = Body & FullName & CR
Body = Body & AddressName & CR &_
"" & CityName & ", " & StateName & " " & PostalName & CR &_
"" & CountryName & CR & CR &_
getlang("langMailProducts") & CR & CR
Do While Not RSItems.EOF
Itemname=RSItems("itemname")
If getconfig("XdeliveryAddress")="Yes" then
Deliveryaddress=RSITEMS("address")
If not isnull(Deliveryaddress) and Deliveryaddress<>"" then
ConvertDeliveryToArray DeliveryArray, Deliveryaddress
GetDeliveryName Itemname, DeliveryArray
end if
end if
Itemname=RemoveHtmlmail(itemname, CR)
Body = Body & "" & itemname & CR
Body = Body & getlang("langProductQuantity") & ": " & RSItems("numitems") & CR
Body = Body & getlang("langProductPrice") & ": " & shopformatcurrency(RSItems("unitprice"),ydecimalpoint) & CR & CR
' add download emails
If getconfig("xendoforderhyperlinkemail")="Yes" Then
downloadlink=GetEmaildownloadLink(RSItems("catalogid"))
If downloadlink <> "" then
Body = Body & getlang("LangorderDownload") & ": " & downloadLink & CR
End If
end if
RSItems.MoveNext
Loop
'
If Not isNULL(rsorder("ocomment")) then
Body = Body & getlang("langOrderComments") & CR
Body = Body & rsorder("ocomment")
End If
Merchant= Body1&Body
Customer= Body2&CR&Body
'Debugwrite merchant
end sub
Function Removehtmlmail(itemname, CR)
dim workrecord, firstchar, morefields, pos, endpos, length
dim token
workrecord=replace(itemname,"
",CR)
workrecord=replace(itemname,"
",CR)
workrecord=replace(itemname,"
",CR)
If getconfig("xemailremovehtml")<>"Yes" then
Removehtmlmail=workrecord
exit function
end if
pos=1
morefields = True
Do While morefields = True
pos=1
pos = InStr(pos, workrecord, "<")
If pos > 0 Then
endpos = InStr(pos, workrecord, ">")
If endpos=0 then
morefields=false
else
length = endpos - pos + 1
token = Mid(workrecord, pos, length)
workrecord=replace(workrecord,token,"")
end if
else
morefields=false
end if
loop
Removehtmlmail=workrecord
end function
%>