📄 send_email.asp
字号:
<%@ Language=VBScript codepage=936 %>
<%
session("mail_server") = "hu"
mailHost=session("mail_server")
%>
<html>
<head>
<title>发送邮件</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="../style/style.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#FFFFFF" text="#000000" link="#000000" vlink="#000000" alink="#000000" name="infocollect">
<%
dim ss,aa,varfname,path
'获取上传文件的文件名'
function getFileName(req)
dim tmp,arr,filename
arr = Split(req,Chr(34),-1,1)
tmp = arr(1)
if tmp = "" then
getFileName = ""
exit function
end if
arr = Split(tmp,"\",-1,1)
filename = arr(UBound(arr))
getFileName = filename
end function
path= server.MapPath("files")
Set obj = Server.CreateObject("LyfUpload.UploadFile")
'获取上传文件的文件名'
varfname=getFileName(obj.request("accessory"))
'判断用户是否添加了附件
if varfname<>"" then
'保存文件到服务器'
ss=obj.SaveFile("accessory", path, false,varfname)
'获取上传文件的扩展名'
aa=obj.filetype("accessory")
else
'没有添加附件
ss = "no file uploaded"
end if
if ss="3" then
Response.Write "此文件在服务器上已经存在!不能覆盖!"
Response.End()
else if ss<> "" then
dim recipientName,recipientEmail,name,email,phone,fax,city,subject,content,emailbody
recipientName=trim(obj.request("recipientName"))
recipientEmail=trim(obj.request("recipientEmail"))
name=trim(obj.request("name"))
email=trim(obj.request("email"))
phone=trim(obj.request("phone"))
fax=trim(obj.request("fax"))
city=trim(obj.request("city"))
subject=trim(obj.request("subject"))
content=obj.request("content")
dim newemail
Set newemail = Server.CreateObject("SMTPsvg.Mailer")
newemail.RemoteHost = mailHost
newemail.FromName = name
newemail.FromAddress = email
newemail.AddRecipient recipientName,recipientEmail
'设置字符集,正确显示中文
newemail.ContentType = "text/plain"
newemail.CustomCharSet = "gb2312"
newemail.Subject = subject
emailbody = recipientName & ":您好"&chr(10)&chr(13)
emailbody = emailbody & content & chr(10)
emailbody = emailbody & "电话:" & phone & chr(10)
emailbody = emailbody & "传真:" & fax & chr(10)
emailbody = emailbody & "城市:" & city & chr(10)&chr(10)
emailbody = emailbody & "致" & chr(10)
emailbody = emailbody & chr(9) & "礼" & chr(10)
emailbody = emailbody & chr(9) & chr(9) & chr(9) & chr(9) & name & chr(10)
emailbody = emailbody & chr(9) & chr(9) & chr(9) & chr(9) & email & chr(10)
emailbody = emailbody & chr(9) & chr(9) & chr(9) & chr(9) & date() & chr(10)
newemail.BodyText = emailbody
if ss <> "no file uploaded" then
'添加附件
newemail.AddAttachment path & "\" & ss
end if
if newemail.SendMail then
flg = 1
else
flg = 0
end if
%>
<table border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td width="20" bgcolor="#dddddd"> </td>
<td align="center" bgcolor="#dddddd"><font size="4"> </font>您的信息</td>
<td width="20" bgcolor="#dddddd"> </td>
</tr>
<tr>
<td width="20" bgcolor="#dddddd"> </td>
<td width="400"><textarea name="emailbody" style="border: 0px none;width:400;height:200;"><%= emailbody %>
</textarea></td>
<td width="20" bgcolor="#dddddd"> </td>
</tr>
<tr>
<td bgcolor="#dddddd"> </td>
<td bgcolor="#dddddd"><%
if ss <> "no file uploaded" then
Response.Write "<img src=""Attachment.gif""> "
Response.Write ss & " " & obj.FileSize & "B"
end if
%> </td>
<td bgcolor="#dddddd"> </td>
</tr>
<tr>
<td width="20" bgcolor="#dddddd"> </td>
<td align="center"><%if(flg=1) then%> <img src="Success.gif" > <%end if%> <%if(flg=0) then%> <img src="fail.gif" > <%end if%></td>
<td width="20" bgcolor="#dddddd"> </td>
</tr>
<tr>
<td width="20" bgcolor="#dddddd"> </td>
<td align="center" bgcolor="#dddddd"><a href="javascript:history.back()"><font size="2">返回</font></a></td>
<td width="20" bgcolor="#dddddd"> </td>
</tr>
</table>
<%
set neweMail= nothing
'删除用户上传的文件
if ss <> "no file uploaded" then
set fso = Server.CreateObject("scripting.filesystemobject")
fso.DeleteFile(path & "\" & ss)
set fso = nothing
end if
end if
end if
%>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -