Example 2 of sending email with asp Jmail

Published: 2006-05-12

```html

Save all the following code content as a jmail.asp file; just change the email information inside to your own.

<%@ Language=VBScript %>

<%

'==================================================

' Parameter Settings

'==================================================

'Modify the recipient email address; the form content will be sent to this mailbox

myemail ="test@test.com"

'Modify the recipient name

myname ="My Company"

'Modify the SMTP server

smtpserver ="smtp.test.com"

'Modify the username and password of the SMTP server

smtpuser ="test@test.com"

smtppwd ="123456"

'Email address corresponding to the relevant SMTP server

'Many SMTP servers, in addition to verifying the username and password, also verify the sender address,

'for example, the SMTP server of 163.net checks whether the sender email address ends with 163.net

'otherwise it will not send; therefore, it is necessary to use the corresponding mailbox as the sender mailbox

smtpemail ="test@test.com"

'==================================================

' Program Starts

'==================================================

tname =Request("t1")

temail =Request("t2")

tother =Request("t3")

tsubject =Request("t4")

tbody =Request("t5")

if tname <> "" and temail <> "" then

set jmail=server.CreateObject ("jmail.message")

jmail.Silent =true

jmail.Charset ="gb2312"

if smtpemail <> "" then

jmail.From ="test@test.com"

else

jmail.From =temail

end if

jmail.FromName =tname

jmail.ReplyTo =temail

jmail.Subject ="Web submission: " & tsubject

jmail.Body =tbody & vbcrlf & vbcrlf & "Contact information: " & tother

jmail.AddRecipient myemail,myname

jmail.MailServerUserName =smtpuser

jmail.MailServerPassWord =smtppwd

isgo=jmail.Send(smtpserver)

if isgo then

msg="Submitted successfully! Thank you for your support."

else

msg="Send failed! Please check whether your email address is filled in correctly."

end if

jmail.Close

set jmail=nothing

end if

%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>Contact Us</title>
</head>
<style type="text/css">
<!--
body,input,textarea{font-size: 12px}
-->
</style>
<body>
<form action=jmail.asp><%=msg%>
<br>Your name:
<br><input name=T1 size=29>
<br>Email:
<br><input name=T2 size=29>
<br>Contact information:
<br><input name=T3 size=29>
<br>Article subject:
<br><input name=T4 size=29>
<br>Article body:
<br><textarea rows=6 cols=28 name=T5>
</textarea>
<br><input type="submit" value="Submit">
</form>
</body></html>

```