⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sendmail.asp

📁 这是一本关于高级软件工程的书籍
💻 ASP
字号:
<%
class SendEmail
	's_subject:邮件标题;s_body:邮件正文;s_stype:邮件发送格式;s_sender;发件人地址;s_AddRecipient:收件人地址;s_AddRecipientBCC:密件地址
	's_AddRecipientCC;抄收地址;s_AppendText:追加内容;s_ServerAddress:邮件服务器地址;s_Prority:发送优先级;s_MailServerUserName:登录邮件服务器所需的用户名;s_MailServerPassword:登录邮件服务器所需的密码
	Public Function SendAspEmail(s_subject,s_body,s_stype,s_sender,s_AddRecipient,s_AddRecipientCC,s_AddRecipientBCC,s_ServerAddress,s_Prority,s_MailServerUserName,s_MailServerPassword)
		on error resume next
		dim objNewMail,e_ServerAddress,e_Prority,e_MailServerUserName,e_MailServerPassword
		dim temp,e_subject,e_body,e_stype,e_sender,e_AddRecipient,e_AddRecipientCC,e_AddRecipientBCC
		dim i
		
		temp=""
		e_subject=""
		e_body=""
		e_stype=""
		e_sender=""
		e_AddRecipient=""
		e_AddRecipientCC=""
		e_AddRecipientBCC=""
		e_ServerAddress=""
		e_Prority=""
		e_MailServerUserName=""
		e_MailServerPassword=""
		
		e_subject=trim(s_subject)
		e_body=trim(s_body)
		e_stype=trim(s_stype)
		e_sender=trim(s_sender)
		e_AddRecipient=trim(s_AddRecipient)
		e_AddRecipientCC=trim(s_AddRecipientCC)
		e_AddRecipientBCC=trim(s_AddRecipientBCC)
		e_ServerAddress=trim(s_ServerAddress)
		e_Prority=s_Prority
		e_MailServerUserName=trim(s_MailServerUserName)
		e_MailServerPassword=trim(s_MailServerPassword)
		
		if trim(e_body)="" or trim(e_sender)="" or trim(e_AddRecipient)="" or trim(e_subject)="" then
			temp="0"
		elseif instr(1,e_sender,"@")=0 or instr(1,e_sender,".")=0 then
			temp="2"
		elseif instr(1,e_AddRecipient,"@")=0 or instr(1,e_AddRecipient,".")=0 then
			temp="3"
		
		else
			if e_stype<>"text/plain" or e_stype<>"text/html" then
				e_stype="text/html"
			elseif cint(e_Prority)>0 and cint(e_Prority)<6  then
				e_Prority=3
			end if
			
			Set objNewMail = Server.CreateObject("JMail.Message")  
				objNewMail.silent = true   
 				objNewMail.logging = true 
				objNewMail.From=e_sender
				
			
				if instr(1,e_AddRecipient,";")=0 then
					objNewMail.AddRecipient e_AddRecipient
				else
					e_AddRecipient=split(e_AddRecipient,";")
					for i=0 to ubound(e_AddRecipient)
						objNewMail.AddRecipient e_AddRecipient(i)
					next
				end if
				
				objNewMail.Subject=e_subject
				objNewMail.Body=e_body
				objNewMail.contentType=e_stype
				objNewMail.Prority=cint(e_Prority)
				objNewMail.Charset = "GB2312"
				
				if trim(e_ServerAddress)="" then
					e_ServerAddress ="pop.163.com "
				end if
				
			
				if trim(e_AddRecipientCC)<>"" then
					if instr(1,e_AddRecipientCC,"@")=0 or instr(1,e_AddRecipientCC,".")=0 then
					else
						
						objNewMail.AddRecipientCC CStr(e_AddRecipientCC)
					end if
				end if
				
				if trim(e_AddRecipientBCC)<>"" then
					if instr(1,e_AddRecipientBCC,"@")=0 or instr(1,e_AddRecipientBCC,".")=0 then
					else
						objNewMail.AddRecipientBCC CStr(e_AddRecipientBCC)
					end if
				end if
				
				if trim(e_MailServerUserName)<>"" then
					objNewMail.MailServerUserName=e_MailServerUserName
				else
					objNewMail.MailServerUserName="mail用户名"
				end if
				
				if trim(e_MailServerPassword)<>"" then
					objNewMail.MailServerPassword=e_MailServerPassword
				else
					objNewMail.MailServerPassword="mail密码"
				end if
				
				
				
				if not objNewMail.Send(e_ServerAddress) then
	                          	temp= "4"	
	                        end if 
			
			Set objNewMail = Nothing 
			
			if trim(temp)<>"" then
			else
				temp="1"
			end if
		end if
		
		SendAspEmail=temp
		
	End Function
end class
%>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -