tkv
11-01-2008, 03:31 PM
JMail, it's a very popular method of sending e-mails using asp. it also can be use with FrontPage or Expression Web
Give it name as jmailExample.asp or whatever you want but you own your risk
<%@LANGUAGE = VBSCRIPT%>
<%Option Explicit%>
<html>
<body>
<%
'NOTE: YOU MUST UPDATE THE FOLLOWING 3 VARIABLES
Dim strMailDomain, strMailUserName, strMailPassword
strMailDomain = "www.yourdomainname.com"
strMailUserName = "you@yourdomainname.com"
strMailPassword = "yourpassword"
' Get the form data from HTML form with 5 fields
Dim name, senderEmail,subject,recipient,body
name = Request.Form("name")
senderEmail = Request.Form("email")
subject = "Regarding " & Request.Form("subject")
recipient = Request.Form("recipient")
body = Request.Form("body")
' Create the JMail message Object
Dim msg
set msg = Server.CreateOBject( "JMail.Message" )
' Enter the sender data
msg.From = senderEmail
msg.FromName = name
'Server Authentication
msg.MailServerUserName = strMailUserName
msg.MailServerPassWord = strMailPassword
' Note that as addRecipient is method and not
' a property, we do not use an equals ( = ) sign
msg.AddRecipient "you@yourdomainname.ccom"
msg.AddRecipientCC "someone@domainname.com"
msg.AddRecipientBCC "somebodyelse@domainname.com"
' The subject of the message
msg.Subject = subject
' And the body
msg.body = body
' Now send the message, using the indicated mailserver
if not msg.Send(strMailDomain) then
Response.write "<pre>" & msg.log & "</pre>"
else
Response.write "Change this content to your own thank you message: Thank you for taking the time to contact us. We will review your request as soon as possible and reply accordingly"
end if
' That's it - you can add additional e-mail addresses as required.
%>
That's it, quite simple! However you are not complete yet. The above code is the code for the asp page and must be saved and named : jmailExample.asp (for ease of this tutorial)
Next we actually need a form so the user can input the details.
Copy and paste the following code and save it as: feedback_form.htm
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252" />
<title>Untitled 1</title>
</head>
<body id="page_content">
<p>Change this to your own wording - something like: 'welcome to our feedback page' </p>
<h3>Please use this form to
contact us.</h3>
<p>ALL FIELDS ARE REQUIRED</strong></p>
<form method="post" action="jmailExample.asp">
Name<br/>
<input name="name" type="text" size="25" />*Required<br />
<br />
Your E-mail<br />
<input name="email" type="text" size="25" />*Required<br />
Select an option<br />
<select name="Subject" size="1" style="width: 147px">
<option>Click to dropdown</option>
<option value="Join our mailing List">Join our mailing List</option>
<option value="Contact Technical">Contact Technical</option>
<option value="FPSE Problem">FPSE Problem</option>
<option value="Contact Billing">Contact Billing</option>
<option value="Link Exchange">Link Exchange</option>
<option value="Comment">Comment</option>
<option value="Question">Question</option>
</select>*Required<br />
<br />
Type your message in the box below - *Required<br />
<textarea name="Body" cols="45" rows="10"></textarea><br />
<input name="Submit1" type="submit" value="submit" /><input name="Reset1" type="reset" value="reset" /></form>
</body>
</html>
The above code creates a form that does the following.
Asks the user for a name
Asks the user for an e-mail
Asks the user to select a topic from the drop down list
Asks the user to make a comment
When submit is clicked the form will be processed and the user will be directed to a thank you page.
When the user visits your feedback form, and fills it in, you will get an e-mail at the account or accounts that you specified in the jmailExample.asp file.
Example:
msg.AddRecipient "you@yourdomainname.com (you@yourdomainname.com)"If you have specified a CC and a BCC address, then the e-mail will be sent to those as well. Note* A carbon copy (CC) mail address will be listed alongside the first e-mail address in the resulting e-mails! If you want to hide a second/third/fourth...... address then use the Blind carbon copy (BCC) code line just keep on adding e-mail addresses.
The processed results.
When your e-mail arrives in your inbox, it will flow as follows:
Regarding: This value is taken from the dropdown list.
The visitors name and the visitors e-mail address [user@userdomainname.com]
If you have set up CC then this will also be shown
Finally the message is shown
Its that simple. But if you use outlook, you can set up rules to process your e-mails as they arrive and have outlook pop them into the folders that you want. In outlook click on tools/rules/ and create a new rule from scratch using the when certain text is in the subject. So if in your dropdown box on the form had a selection for site feed back, the resultant e-mail would have the subject set as...
Regarding Site feedback
So in your outlook rule, you would have the above text, then when someone fills in the form and selects feed back, you will get the e-mail and it will go directly to the feedback folder that you have asked outlook to place it in. This does not effect how the other recipients see the e-mail, it is up to them to set their own rules in their own outlook.
Have fun with this simple and easy method of e-mailing forms in Expression Web.
Give it name as jmailExample.asp or whatever you want but you own your risk
<%@LANGUAGE = VBSCRIPT%>
<%Option Explicit%>
<html>
<body>
<%
'NOTE: YOU MUST UPDATE THE FOLLOWING 3 VARIABLES
Dim strMailDomain, strMailUserName, strMailPassword
strMailDomain = "www.yourdomainname.com"
strMailUserName = "you@yourdomainname.com"
strMailPassword = "yourpassword"
' Get the form data from HTML form with 5 fields
Dim name, senderEmail,subject,recipient,body
name = Request.Form("name")
senderEmail = Request.Form("email")
subject = "Regarding " & Request.Form("subject")
recipient = Request.Form("recipient")
body = Request.Form("body")
' Create the JMail message Object
Dim msg
set msg = Server.CreateOBject( "JMail.Message" )
' Enter the sender data
msg.From = senderEmail
msg.FromName = name
'Server Authentication
msg.MailServerUserName = strMailUserName
msg.MailServerPassWord = strMailPassword
' Note that as addRecipient is method and not
' a property, we do not use an equals ( = ) sign
msg.AddRecipient "you@yourdomainname.ccom"
msg.AddRecipientCC "someone@domainname.com"
msg.AddRecipientBCC "somebodyelse@domainname.com"
' The subject of the message
msg.Subject = subject
' And the body
msg.body = body
' Now send the message, using the indicated mailserver
if not msg.Send(strMailDomain) then
Response.write "<pre>" & msg.log & "</pre>"
else
Response.write "Change this content to your own thank you message: Thank you for taking the time to contact us. We will review your request as soon as possible and reply accordingly"
end if
' That's it - you can add additional e-mail addresses as required.
%>
That's it, quite simple! However you are not complete yet. The above code is the code for the asp page and must be saved and named : jmailExample.asp (for ease of this tutorial)
Next we actually need a form so the user can input the details.
Copy and paste the following code and save it as: feedback_form.htm
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252" />
<title>Untitled 1</title>
</head>
<body id="page_content">
<p>Change this to your own wording - something like: 'welcome to our feedback page' </p>
<h3>Please use this form to
contact us.</h3>
<p>ALL FIELDS ARE REQUIRED</strong></p>
<form method="post" action="jmailExample.asp">
Name<br/>
<input name="name" type="text" size="25" />*Required<br />
<br />
Your E-mail<br />
<input name="email" type="text" size="25" />*Required<br />
Select an option<br />
<select name="Subject" size="1" style="width: 147px">
<option>Click to dropdown</option>
<option value="Join our mailing List">Join our mailing List</option>
<option value="Contact Technical">Contact Technical</option>
<option value="FPSE Problem">FPSE Problem</option>
<option value="Contact Billing">Contact Billing</option>
<option value="Link Exchange">Link Exchange</option>
<option value="Comment">Comment</option>
<option value="Question">Question</option>
</select>*Required<br />
<br />
Type your message in the box below - *Required<br />
<textarea name="Body" cols="45" rows="10"></textarea><br />
<input name="Submit1" type="submit" value="submit" /><input name="Reset1" type="reset" value="reset" /></form>
</body>
</html>
The above code creates a form that does the following.
Asks the user for a name
Asks the user for an e-mail
Asks the user to select a topic from the drop down list
Asks the user to make a comment
When submit is clicked the form will be processed and the user will be directed to a thank you page.
When the user visits your feedback form, and fills it in, you will get an e-mail at the account or accounts that you specified in the jmailExample.asp file.
Example:
msg.AddRecipient "you@yourdomainname.com (you@yourdomainname.com)"If you have specified a CC and a BCC address, then the e-mail will be sent to those as well. Note* A carbon copy (CC) mail address will be listed alongside the first e-mail address in the resulting e-mails! If you want to hide a second/third/fourth...... address then use the Blind carbon copy (BCC) code line just keep on adding e-mail addresses.
The processed results.
When your e-mail arrives in your inbox, it will flow as follows:
Regarding: This value is taken from the dropdown list.
The visitors name and the visitors e-mail address [user@userdomainname.com]
If you have set up CC then this will also be shown
Finally the message is shown
Its that simple. But if you use outlook, you can set up rules to process your e-mails as they arrive and have outlook pop them into the folders that you want. In outlook click on tools/rules/ and create a new rule from scratch using the when certain text is in the subject. So if in your dropdown box on the form had a selection for site feed back, the resultant e-mail would have the subject set as...
Regarding Site feedback
So in your outlook rule, you would have the above text, then when someone fills in the form and selects feed back, you will get the e-mail and it will go directly to the feedback folder that you have asked outlook to place it in. This does not effect how the other recipients see the e-mail, it is up to them to set their own rules in their own outlook.
Have fun with this simple and easy method of e-mailing forms in Expression Web.