Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to send a submitted form to an email address?

Status
Not open for further replies.

gacon

Programmer
Dec 25, 2003
2
0
0
VN
I got a form which is used for clients to fill their info. When the clients submit the form, i want the submitted form will be sent to my email as an attachment. Is that possible?? Please send me the syntax to wirte that function!!!
 
yes, it is possible. you'll need to know which email component is installed on the server. That will determine the exact syntax that you would need. CDONTS and JMail are a couple of the most common and their syntax is very similar. code below doesn't include sending as an attachment but will give you the basic idea. we've been requesting the form contents and just concatenate a string called "body".
'SENDING EMAIL
Function SendEmail(subject,recipient,priority,body)
' Set JMail = Server.CreateObject("JMail.SMTPMail")
' JMail.ServerAddress = "myemailserver.com
' JMail.Sender = "myemail@mymail.com
' JMail.Subject = subject
' JMail.AddRecipient recipient
' JMail.Body = body
' JMail.Priority = priority
' JMail.ContentType = "text/html"
' JMail.AddHeader "Originating-IP", Request.ServerVariables("REMOTE_ADDR")
' JMail.Execute
' Set JMail=nothing

'CDONTS
Set objMail = Server.CreateObject("CDONTS.NewMail")
objMail.From = "myemail@mymail.com"
objMail.Subject = subject
objMail.To=recipient
objMail.Body=body
objMail.Importance=priority
objMail.MailFormat=0
objMail.BodyFormat=0
objMail.Send
Set objMail = Nothing
End Function

hth
mb

"Where's the Ka-Boom? There's supposed to be an Earth-shattering Ka-Boom!"
Marvin the Martian
 
Thank you "Hithere"!
yep, i'm using the CDONTS, but right now i make it get info from the form and display as a webpage which i found a bit too long and waste of time, that's why i got an idea to send the submitted form straight away as an attachment! Here is what i'm using now:
_________________________________________________
sHTML= &quot;<html><head>&quot;
sHTML=sHTML + &quot;<title> Visitor Information and Travel Approval to Vietnam </title> &quot;
sHTML=sHTML + &quot;</head><body><br>&quot;
sHTML=sHTML + &quot;<p><b><center>VISITOR INFORMATION AND TRAVEL APPROVAL TO VIETNAM</b></center><br>&quot;
sHTML=sHTML + &quot;<p><b><u>SPONSOR INFORMATION</b></u><br>&quot;
sHTML=sHTML + &quot;<b>Name:</b> &quot; + Request.Form(&quot;sponsor_name&quot;) + &quot;<br>&quot;
sHTML=sHTML + &quot;<b>Dept:</b> &quot; + Request.Form(&quot;dept&quot;) + &quot;<br>&quot;
sHTML=sHTML + &quot;<b>Extn:</b> &quot; + Request.Form(&quot;extn&quot;) + &quot;<br>&quot;
sHTML=sHTML + &quot;<b>Extn:</b> &quot; + Request.Form(&quot;charge_code&quot;) + &quot;<br>&quot;
sHTML=sHTML + &quot;<p><b><u>VISITOR INFORMATION</b></u><br>&quot;
sHTML=sHTML + &quot;<b>Name:</b> &quot; + Request.Form(&quot;visitor_name&quot;) + &quot;<br>&quot;
sHTML=sHTML + &quot;<b>Company:</b> &quot; + Request.Form(&quot;company&quot;) + &quot;<br>&quot;
sHTML=sHTML + &quot;<b>Location:</b> &quot; + Request.Form(&quot;location&quot;) + &quot;<br>&quot;
sHTML=sHTML + &quot;<b>Phone:</b> &quot; + Request.Form(&quot;phone&quot;) + &quot;<br>&quot;
sHTML=sHTML + &quot;<b>Passport:</b> &quot; + Request.Form(&quot;passport_num&quot;) + &quot;<br>&quot;
sHTML=sHTML + &quot;<b>Hotel/Accomm:</b> &quot; + accomm + &quot;<br>&quot;
sHTML=sHTML + &quot;<b>SSN:</b> &quot; + Request.Form(&quot;ssn&quot;) + &quot;<br>&quot;
sHTML=sHTML + &quot;<b>Reason for Travel:</b> &quot; + Request.Form(&quot;reason&quot;) + &quot;<br>&quot;
sHTML=sHTML + &quot;<p><b><u>ARRIVAL INFORMATION:</b></u><br>&quot;
sHTML=sHTML + &quot;<b>Arrival City:</b> &quot; + city + &quot;<br>&quot;
sHTML=sHTML + &quot;<b>Arrival Date (dd/mm/yy</b>): &quot; + arr_date + &quot;<br>&quot;
sHTML=sHTML + &quot;<b>Arrival Time:</b> &quot; + arr_time + &quot;<br>&quot;
sHTML=sHTML + &quot;<b>Flight:</b> &quot; + Request.Form(&quot;aflight&quot;) + &quot;<br>&quot;
sHTML=sHTML + &quot;<p><b><u>DEPARTURE INFORMATION:</b></u><br>&quot;
sHTML=sHTML + &quot;<b>Departure Date (dd/mm/yy):</b> &quot; + dep_date + &quot;<br>&quot;
sHTML=sHTML + &quot;<b>Departure Time:</b> &quot; + dep_time + &quot;<br>&quot;
sHTML=sHTML + &quot;<b>Flight:</b> &quot; + Request.Form(&quot;dflight&quot;) + &quot;<br>&quot;
sHTML=sHTML + &quot;<b><p>First Time Traveler to Vietnam?</b> &quot; + Request.Form(&quot;r1&quot;) + &quot;<br>&quot;
sHTML=sHTML + &quot;<b>Visa Request Processed via Hanoi?</b> &quot; + vis_proc + &quot;<br>&quot;
sHTML=sHTML + &quot;<b>Country in which Passport was Issued:</b> &quot; + Request.Form(&quot;country_passport&quot;) + &quot;<br>&quot;
sHTML=sHTML + &quot;<b>Locations to be visited In Vietnam:</b> &quot; + Request.Form(&quot;visit_location&quot;) + &quot;<br>&quot;
sHTML=sHTML + &quot;<b>Emergency Contact at Home/Office:</b> &quot; + Request.Form(&quot;contact&quot;) + &quot;<br>&quot;
sHTML=sHTML + &quot;<p><b><u>ENTRY VISA APPLICATION:</b></u><br>&quot;
sHTML=sHTML + &quot;<b>Date of birth (dd/mm/yy):</b> &quot; + birth_date + &quot;<br>&quot;
sHTML=sHTML + &quot;<b>Nationality:</b> &quot; + nation + &quot;<br>&quot;
sHTML=sHTML + &quot;<b>Passport Number:</b> &quot; + passno + &quot;<br>&quot;
sHTML=sHTML + &quot;<b>Country in which passport was issued:</b> &quot; + issuecountry + &quot;<br>&quot;
sHTML=sHTML + &quot;<b>Date of Issue:</b> &quot; + issue_date + &quot;<br>&quot;
sHTML=sHTML + &quot;<b>Place of Issue:</b> &quot; + issueplace + &quot;<br>&quot;
sHTML=sHTML + &quot;<b>Date of Expiration:</b> &quot; + expire_date + &quot;<br>&quot;
sHTML=sHTML + &quot;<b>Place of visa issue:</b> &quot; + visa_issue + &quot;<br>&quot;
sHTML=sHTML + &quot;<b>Multi visa request:</b> &quot; + mul_visa + &quot;<br>&quot;
sHTML=sHTML + &quot;<b>Single of visa issue:</b> &quot; + single_visa + &quot;<br>&quot;
sHTML=sHTML + &quot;<br> &quot;
sHTML=sHTML + &quot;<b>APPROVAL</b> &quot;+ &quot;<br>&quot;
sHTML=sHTML + &quot;<br> &quot;
sHTML=sHTML + &quot;<br> &quot;
sHTML=sHTML + &quot;<br> &quot;
sHTML=sHTML + &quot;<br> &quot;
sHTML=sHTML + &quot;_______________________________________________ &quot; + &quot;<BR>&quot;
sHTML=sHTML + &quot;<b>Georg Storaker - President</b> &quot;+ &quot;<br>&quot;
sHTML=sHTML + &quot;<b>ConocoPhillips (UK) Ltd - Vietnam</b> &quot;+ &quot;<br>&quot;
sHTML=sHTML + &quot;</body></hmtl>&quot;

set objMail= CreateObject(&quot;CDONTS.Newmail&quot;)
objMail.From = cstr(Request.Form(&quot;e-mail&quot;))
objMail.To =&quot;tthuyen@newhorizons.com.vn&quot;
objMail.Subject = &quot;Visitor Information Request&quot;
objMail.BodyFormat = cdoBodyFormatHTML
objMail.MailFormat = cdoMailFormatMIME
objMail.Body = sHTML
objMail.Send
Set objMail=Nothing
__________________________________________________

i have found a sending attachment syntax:
objMail.AddAttachment &quot;filepath&quot;
But can't work it out to send a submitted form!


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top