Problem with ASP and Mail

Results 1 to 2 of 2

Thread: Problem with ASP and Mail

  1. #1
    Dhaval Bhagat Guest

    Default Problem with ASP and Mail

    I have a form, which on submit i write data to the database. But, I also want to mail the content of the form to me. So, how do i achieve both together? Please email at dbhagat@cse.fau.edu

  2. #2
    hummyz Guest

    Default RE: Problem with ASP and Mail

    Here is what I did last year:<BR><BR>&#060;% &#039 ************************************************** **********************************************<BR> &#039 /Survey/submit.asp<BR> &#039<BR> &#039 Author : Rob Barnett (rbarnett@nwadmin.com)<BR> &#039 Created : November 16, 1998<BR> &#039<BR> &#039 Purpose :<BR> &#039 Requires "DMID" field.<BR> &#039<BR> &#039 ************************************************** **********************************************<BR> <BR> title="Small Business Referral Database"<BR> &#039on error resume next<BR><BR> &#039********************************************* ********<BR> &#039* DEFINE FORM VARIABLES *<BR> &#039********************************************* ********<BR><BR> &#039 Error checking for default.asp<BR> companyname = Request.QueryString("companyname")<BR> street1 = Request.QueryString("street1")<BR> street2 = Request.QueryString("street2")<BR> city = Request.QueryString("city")<BR> province = Request.QueryString("province")<BR> postalcode = Request.QueryString("postalcode")<BR> Fname = Request.QueryString("Fname")<BR> Lname = Request.QueryString("Lname")<BR> email = Request.QueryString("email")<BR> PhoneAC = Request.Querystring("PhoneAC")<BR> PhoneNum = Request.Querystring("PhoneNum")<BR> FaxAC = Request.Querystring("FaxAC")<BR> FaxNum = Request.Querystring("FaxNum")<BR> windows98 = Request.Querystring("windows98")<BR> ntworkstation = Request.Querystring("ntworkstation")<BR> ntserver = Request.Querystring("ntserver")<BR> office97 = Request.Querystring("office97")<BR> smbusserver = Request.Querystring("smbusserver")<BR> outlook98 = Request.Querystring("outlook98")<BR> word97 = Request.Querystring("word97")<BR> access97 = Request.Querystring("access97")<BR> Excel97 = Request.Querystring("Excel97")<BR> powerpoint97 = Request.Querystring("powerpoint97")<BR> publisher98 = Request.Querystring("publisher98")<BR> project98 = Request.Querystring("project98")<BR> macoffice = Request.Querystring("macoffice")<BR> backoffice = Request.Querystring("backoffice")<BR> excserver = Request.Querystring("excserver")<BR> sqlserver = Request.Querystring("sqlserver")<BR> siteserver = Request.Querystring("siteserver")<BR> proxyserver = Request.Querystring("proxyserver")<BR> snaserver = Request.Querystring("snaserver")<BR> geography = Request.Querystring("geography")<BR> languag = Request.Querystring("languag")<BR> mpi = Request.Querystring("mpi")<BR> mpiurl = Request.Querystring("mpiurl")<BR> license = Request.Querystring("license")<BR> mol = Request.Querystring("mol")<BR> molurl = Request.Querystring("molurl")<BR> training = Request.Querystring("training")<BR> technical = Request.Querystring("technical")<BR> network = Request.Querystring("network")<BR> msproduct = Request.QueryString("msproduct")<BR> servicing = Request.QueryString("servicing")<BR> companyware = Request.Querystring("companyware")<BR> minimum = Request.QueryString("minimum")<BR><BR> &#039Initial Data cleanup: Money Fields<BR> msproduct = replace(msproduct, "$", "")<BR> msproduct = replace(msproduct, ",", "")<BR> msproduct = replace(msproduct, "+", "")<BR> msproduct = replace(lcase(msproduct), "k", "000")<BR><BR> servicing = replace(servicing, "$", "")<BR> servicing = replace(servicing, ",", "")<BR> servicing = replace(servicing, "+", "")<BR> servicing = replace(lcase(servicing), "k", "000")<BR><BR><BR> &#039********************************************* ********<BR> &#039* SERVER SIDE ERROR CHECKING *<BR> &#039********************************************* ********<BR><BR> &#039Check validity of all fields. If errors occur, redirect to default.asp<BR> &#039with "error=fields". Each field with an error will be sent back as<BR> &#039"fieldname_err=true". Additional special errors will be sent back as<BR> &#039"fieldnameN_err=true".<BR><BR> &#039**** ERROR1: Check entries ****<BR><BR> Dim qstring, blankfields, error<BR> qstring = "?from=submit.asp"<BR><BR> For Each var in Request.QueryString<BR> qstring = qstring & "&" & var & "=" & server.URLEncode(request.querystring(var))<BR> Next<BR><BR> &#039Automated check for blanks<BR> sub errorcheck(var)<BR> if request.querystring(var) = "" then<BR> qstring = qstring & "&" & var & "_err=true"<BR> error = "true"<BR> blankfields = "true"<BR> end if<BR> end sub<BR><BR> Dim Variablelist<BR> Variablelist = Array("companyname","street1","city","province","p ostalcode","Fname","Lname","email","PhoneAC","Phon eNum","FaxAC","FaxNum","windows98","ntworkstation" ,"ntserver","office97","smbusserver","outlook98"," word97","excel97","access97","powerpoint97","publi sher98","project98","macoffice","backoffice","excs erver","sqlserver","siteserver","proxyserver","sna server","geography","languag","mpi","license","mol ","training","technical","network","msproduct","se rvicing","companyware","minimum")<BR><BR> For Each var in Variablelist<BR> errorcheck(var)<BR> next<BR><BR> if blankfields = "true" then<BR> qstring = qstring & "&blankfields=true"<BR> end if<BR><BR> &#039Special requirements<BR> <BR> if (len(companyware) &#062; 300) then<BR> qstring = qstring & "&companyware_err2=true"<BR> error = true<BR> end if<BR> <BR> if (len(msproduct) &#062; 10) then<BR> qstring = qstring & "&msproduct_err2=true"<BR> error = true<BR> end if<BR> <BR> if (len(servicing) &#062; 10) then<BR> qstring = qstring & "&servicing_err2=true"<BR> error = true<BR> end if<BR><BR> if MPI = "1" then<BR> if instr(lcase(MPIURL),"http")=0 then<BR> qstring = qstring & "&MPIURL_err2=true"<BR> error = "true"<BR> end if<BR> end if<BR><BR> if MOL = "1" then<BR> if instr(lcase(MOLURL),"http")=0 then<BR> qstring = qstring & "&MOLURL_err2=true"<BR> error = "true"<BR> end if<BR> end if<BR><BR> if (IsNumeric(phoneac)=0) then<BR> qstring = qstring & "&phoneac_err2=true"<BR> error = "true"<BR> end if<BR><BR> if (len(PhoneNum) &#060; 7) then<BR> qstring = qstring & "&PhoneNum_err2=true"<BR> error = "true"<BR> end if<BR><BR> if instr(email,"@") = false or instr(email,".") = false or len(email) &#060; 6 then<BR> qstring = qstring & "&email_err2=true"<BR> error = "true"<BR> end if<BR><BR> if (IsNumeric(servicing)=0) then<BR> qstring = qstring & "&servicing_err2=true"<BR> error = "true"<BR> end if<BR><BR> if (IsNumeric(msproduct)=0) then<BR> qstring = qstring & "&msproduct_err2=true"<BR> error = "true"<BR> end if<BR><BR> if (len(trim(postalcode)) &#060;&#062; 6) then<BR> qstring = qstring & "&postalcode_err2=true"<BR> error = "true"<BR> elseif IsNumeric(mid(Postalcode,1,1))=1 or IsNumeric(mid(Postalcode,2,1))=0 or IsNumeric(mid(Postalcode,3,1))=1 or IsNumeric(mid(Postalcode,4,1))=0 or IsNumeric(mid(Postalcode,5,1))=1 or IsNumeric(mid(Postalcode,6,1))=0 then<BR> qstring = qstring & "&postalcode_err2=true"<BR> error = "true"<BR> end if<BR><BR><BR> &#039********************************************* ********<BR> &#039* If error, redirect to default.asp *<BR> &#039********************************************* ********<BR><BR> if (error = "true") then<BR> Response.redirect("/survey/default.asp" & qstring & "&error=true")<BR> end if<BR><BR> &#039************* OPEN DATABASE CONNECTION **************<BR><BR> Set Con = Server.CreateObject("ADODB.Connection")<BR> Con.Open "DRIVER=SQL Server; SERVER=Atlas; Database=MSCanada; UID=WebUser; PWD=!WebUser!"<BR><BR> companyname = replace(companyname, "&#039", "&#039&#039")<BR> Fname = replace(Fname, "&#039", "&#039&#039")<BR> Lname = replace(Lname, "&#039", "&#039&#039")<BR> street1 = replace(street1, "&#039", "&#039&#039")<BR> street2 = replace(street2, "&#039", "&#039&#039")<BR> city = replace(city, "&#039", "&#039&#039")<BR> province = replace(province, "&#039", "&#039&#039")<BR> geography = replace(geography, "&#039", "&#039&#039")<BR> companyware = replace(companyware, "&#039", "&#039&#039")<BR> Email = replace(email, "&#039", "&#039&#039")<BR> MPIURL = replace(MPIURL, "&#039", "&#039&#039")<BR> MOLURL = replace(MOLURL, "&#039", "&#039&#039")<BR> postalcode = replace(postalcode, "&#039", "")<BR> msproduct = replace(msproduct, "&#039", "&#039&#039")<BR> servicing = replace(servicing, "&#039", "&#039&#039")<BR> PhoneNum = replace(PhoneNum, "&#039", "")<BR> FaxNum = replace(FaxNum, "&#039", "")<BR> <BR> <BR> &#039CHECK DISTRICT USING MSDA DATABASE<BR> <BR> Set Con2 = Server.CreateObject("ADODB.Connection")<BR> Con2.Open "DRIVER=SQL Server; SERVER=Atlas; Database=MSDA; UID=MSDA_User; PWD=msdirectaccess"<BR><BR> PostalCode1 = left(PostalCode,1)<BR> PostalCode2 = left(PostalCode,2)<BR> PostalCode3 = left(PostalCode,3)<BR> If PostalCode1 = "V" then<BR> PostalCodeLookup = PostalCode3<BR> elseif PostalCode = "J" or PostalCode = "S" or PostalCode = "T" then<BR> PostalCodeLookup = PostalCode2<BR> else<BR> PostalCodeLookup = PostalCode1<BR> end if<BR> qryGetDistrict = "select district from vr_CDNPostal where PostalCode = &#039" & postalcodelookup & "&#039"<BR> set rsGetDistrict = con2.execute(qryGetDistrict)<BR> If rsGetDistrict.eof = true then<BR> district = 40<BR> else<BR> district = rsGetDistrict("District")<BR> end if<BR> con2.close<BR><BR> &#039********************************************* ********<BR> &#039* Insert Into Database *<BR> &#039********************************************* ********<BR><BR> &#039Insert the company<BR> qryInsertCompany = "INSERT Companies (companyname, street1, street2, city, province, postalcode, Fname, Lname, email, PhoneAC, PhoneNum, FaxAC, FaxNum, windows98, ntworkstation, ntserver, office97, smbusserver, outlook98, word97, excel97, access97, powerpoint97, publisher98, project98, macoffice, backoffice, excserver, sqlserver, siteserver, proxyserver, snaserver, geography, languag, mpi, mpiurl, license, mol, molurl, training, technical, network, msproduct, servicing, companyware, minimum, status, district) VALUES (&#039" & companyname & "&#039, &#039" & street1 & "&#039, &#039" & street2 & "&#039,&#039" & city & "&#039,&#039" & province & "&#039,&#039" & postalcode & "&#039,&#039" & Fname & "&#039,&#039" & Lname & "&#039,&#039" & email & "&#039,&#039" & PhoneAC & "&#039,&#039" & PhoneNum & "&#039,&#039" & FaxAC & "&#039,&#039" & FaxNum & "&#039,&#039" & windows98 & "&#039,&#039" & ntworkstation & "&#039,&#039" & ntserver & "&#039,&#039" & office97 & "&#039,&#039" & smbusserver & "&#039,&#039" & outlook98 & "&#039,&#039" & word97 & "&#039,&#039" & excel97 & "&#039,&#039" & access97 & "&#039,&#039" & powerpoint97 & "&#039,&#039" & publisher98 & "&#039,&#039" & project98 & "&#039,&#039" & macoffice & "&#039,&#039" & backoffice & "&#039,&#039" & excserver & "&#039,&#039" & sqlserver & "&#039,&#039" & siteserver & "&#039,&#039" & proxyserver & "&#039,&#039" & snaserver & "&#039,&#039" & geography & "&#039,&#039" & languag & "&#039,&#039" & mpi & "&#039,&#039" & mpiurl & "&#039,&#039" & license & "&#039,&#039" & mol & "&#039,&#039" & molurl & "&#039,&#039" & training & "&#039,&#039" & technical & "&#039,&#039" & network & "&#039," & msproduct & "," & servicing & ",&#039" & companyware & "&#039,&#039" & minimum & "&#039,0," & district & ")"<BR> &#039Response.Write qryInsertCompany<BR> con.execute(qryInsertCompany)<BR><BR> &#039********************************************* ********<BR> &#039* Send Confirmation E-Mail *<BR> &#039********************************************* ********<BR><BR> &#039Send confirmation mail to user or to self<BR> &#039At the top of the page you have all the variable names. You may have used the POST method request.form("companyname") etc.<BR> &#039so instead of using the message below you could say:<BR> &#039message = "Here is the form data I am sending myself" & vbCRLF & vbCRLF<BR> &#039message = message & "Company Name: " & companyname & vbCRLF<BR> &#039message = message & "Next Form Name: " & nextname & vbCRLF <BR> message = "Thank you for expressing an interest in Microsoft Canada&#039s Small Business Reseller Referral Database. Your Request for Information form (RFI) has been received and will be reviewed. Please remember that completion of this RFI does not guarantee placement on the Small Business Reseller Referral database. " & vbcrlf & vbcrlf & "At Microsoft Canada&#039s sole discretion, qualifying resellers will be added to the Small Business Reseller Referral Database. We will notify, via email, by the end of the day Friday February 26, the companies that have been added to the referral service. We will not notify the companies that have not been added to the referral service. " & vbcrlf & vbcrlf & "Thank you again for your time and interest. " & vbcrlf & vbcrlf & "Anne McKeon "& vbcrlf & "Microsoft Canada" <BR><BR> set myMail = CreateObject("CDONTS.NewMail")<BR> myMail.From = "Microsoft Canada Direct Access Site (Automated Reply) &#060;ntrebate@microsoft.com&#062;"<BR> myMail.To = "youremail@blah.com"<BR> myMail.Subject = "Small Business Reseller Referal Database"<BR> myMail.Body = message<BR> myMail.Send<BR> Set myMail = Nothing<BR><BR> &#039********************************************* ********<BR> &#039* Redirect to Follow-up Page *<BR> &#039********************************************* ********<BR><BR> response.redirect("/directaccess/review/submit/followup.asp?fname=" & server.urlencode(fname) & "&lname=" & server.urlencode(lname))<BR><BR> %&#062;<BR><BR>Any more questions just ask.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •