I have an ASP application that we ported from one Webhosting company to another. The application was written several years ago by developers that are long out of reach and it formerly used ASPMail version 4.x for its sendmail routine. The new hosting company has persits libraries instead and I am trying to convert the sendmail routines to use persits and get the same result which is an email with a dynamically generated text attachment within the email.
Unfortunately, the persits code makes the text inline in the message as opposed to attached like it used to be. I have altered the code as little as possible other than substituting the various WEBMail functions with what seem to be equivalent Persits functions.
Here is my code:
BOUNDARY = "----xxxxxx"
TEXT_HEADER = "--" & BOUNDARY & VBCrLf & "Content-Type: text/plain;" & VBCrLf & _
"Content-Transfer-Encoding: 7bit" & VBCrLf & VBCrLf
ATTACH_HEADER = "--" & BOUNDARY & VBCrLf & "Content-Type: application/octet-stream; name=update" & CLng(Date) & Session.SessionID & ".txt" & VBCrLf & _
"Content-Disposition: attachment; filename=update" & CLng(Date) & Session.SessionID & ".txt" & VBCrLf & _
"Content-Transfer-Encoding: 7bit" & VBCrLf & VBCrLf
MP_FOOTER = "--" & BOUNDARY & "--" & VBCrLf
'Get Rep ID
rep_id = Get_RepID()
FileContent = Session("referer") & "," & _
Replace(Request.Form("lastname"),",",".") & "," & _
Replace(Request.Form("firstname"),",",".") & "," & _
Replace(Request.Form("email"),",",".") & "," & _
pum & "," & _
pud & "," & _
puy & "," & _
Request.Form("origphoneA") & Request.Form("origphoneB") & Request.Form("origphoneC") & "," & _
Request.Form("origphone2A") & Request.Form("origphone2B") & Request.Form("origphone2C") & "," & _
Replace(Request.Form("origadd"),",",".") & "," & _
Replace(Request.Form("origcity"),",",".") & "," & _
GetStateName(Request.Form("origstateID")) & "," & _
Replace(Request.Form("origzip"),",",".") & "," & _
GetCountryName(GetCountryID(Request.Form("origstateID"))) & "," & _
Request.Form("destphoneA") & Request.Form("destphoneB") & Request.Form("destphoneC") & "," & _
Request.Form("destphone2A") & Request.Form("destphone2B") & Request.Form("destphone2C") & "," & _
Replace(Request.Form("destadd"),",",".") & "," & _
Replace(Request.Form("destcity"),",",".") & "," & _
GetStateName(Request.Form("deststateID")) & "," & _
Replace(Request.Form("destzip"),",",".") & "," & _
GetCountryName(GetCountryID(Request.Form("deststateID"))) & "," & _
Request.Form("running") & "," & _
Request.Form("typeauto") & "," & _
Request.Form("automake1") & "," & _
Request.Form("automodel1") & "," & _
Request.Form("autoyear") & "," & _
Request.Form("running2") & "," & _
Request.Form("typeauto2") & "," & _
Request.Form("automake2") & "," & _
Request.Form("automodel2") & "," & _
Request.Form("autoyear2") & "," & rep_id
Message = "Referral: " & Session("referer") & vbcrlf & _
"Name: " & Request.Form("lastname") & ", " & Request.Form("firstname") & vbcrlf & _
"E-mail: " & Request.Form("email") & vbcrlf & _
"Date of Move: " & pum & " " & pud & ", " & puy & vbcrlf & _
"Phone: " & Request.Form("origphoneA") & Request.Form("origphoneB") & Request.Form("origphoneC") & vbcrlf & _
"Office: " & Request.Form("origphone2A") & Request.Form("origphone2B") & Request.Form("origphone2C") & vbcrlf & _
"Origin Address: " & Request.Form("origadd") & vbcrlf & _
Request.Form("origcity") & ", " & GetStateName(Request.Form("origstateID")) & vbcrlf & _
Request.Form("origzip") & ", " & GetCountryName(GetCountryID(Request.Form("origstateID"))) & vbcrlf & _
vbcrlf & _
">> Destination" & vbcrlf & _
"Phone: " & Request.Form("destphoneA") & Request.Form("destphoneB") & Request.Form("destphoneC") & vbcrlf & _
"Office: " & Request.Form("destphone2A") & Request.Form("destphone2B") & Request.Form("destphone2C") & vbcrlf & _
"Destination Address: " & Request.Form("destadd") & vbcrlf & _
Request.Form("destcity") & ", " & GetStateName(Request.Form("deststateID")) & vbcrlf & _
Request.Form("destzip") & ", " & GetCountryName(GetCountryID(Request.Form("deststateID"))) & vbcrlf & _
">>First Auto-------------------------" & vbcrlf & _
"Auto Make: " & Request.Form("automake1") & vbcrlf & _
"Auto Model: " & Request.Form("automodel1") & vbcrlf & _
"Year: " & Request.Form("autoyear") & vbcrlf & _
"Running Condition: " & Request.Form("running") & vbcrlf & _
"Auto Type: " & Request.Form("typeauto") & vbcrlf & _
">>Second Auto------------------------" & vbcrlf & _
"Auto Make: " & Request.Form("automake2") & vbcrlf & _
"Auto Model: " & Request.Form("automodel2") & vbcrlf & _
"Year: " & Request.Form("autoyear2") & vbcrlf & _
"Running Condition: " & Request.Form("running2") & vbcrlf & _
"Auto Type: " & Request.Form("typeauto2") & vbcrlf & _
"Moving Info Opt-in? " & Request.Form("opt")
Set Mail = Server.CreateObject("Persits.MailSender")
Mail.Host = "mail.mydomain.com"
Mail.Username = "anaccount@mydomain.com"
Mail.Password = "password"
Mail.From = "from@mydomain.com"
Mail.FromName = "From Form"
Mail.AddAddress "destination@mydomain.com"
Mail.Subject = "Subject: " & Request.Form("firstname") & " " & Request.Form("lastname")
Mail.Body = TEXT_HEADER & Message & VBCrLf & ATTACH_HEADER & FileContent & VBCrLf & MP_FOOTER
On Error Resume Next
Mail.SendToQueue
Set Mail = Nothing