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

📄 functions_send_mail.asp

📁 简单的asp论坛源码系统,很适用于初学者!界面简洁,功能齐全
💻 ASP
📖 第 1 页 / 共 2 页
字号:
		

			With objCDOMail
				'Who the e-mail is from
				.From = strFromEmailName & " <" & strFromEmailAddress & ">"

				'Who the e-mail is sent to
				.To = strRecipientName & " <" & strRecipientEmailAddress & ">"

				'The subject of the e-mail
				.Subject = strSubject

				'The main body of the e-amil
				.Body = strEmailBodyMessage & strEmailBodyAppendMessage

				'Set the e-mail body format (0=HTML 1=Text)
				If blnHTML = True Then
					.BodyFormat = 0
				Else
					.BodyFormat = 1
				End If

				'Set the mail format (0=MIME 1=Text)
				.MailFormat = 0

				'Importance of the e-mail (0=Low, 1=Normal, 2=High)
				.Importance = 1

				'Send the e-mail
				.Send
			End With

			'Close the server mail object
			Set objCDOMail = Nothing




		'******************************************
		'***  	  w3 JMail mail component      ****
		'******************************************

		'JMail component
		Case "Jmail"

			'Create the e-mail server object
			Set objJMail = Server.CreateObject("JMail.SMTPMail")
			
			'Check to see if an error has occurred
			'If an error has occurred write an error to the page
			If Err.Number <> 0 Then Call errorMsg("An error has occurred while sending an email.<br />Please check that the JMail email component is installed on the server.", "create_JMail_3_object", "functions_send_mail.asp")
		

			With objJMail
				'Out going SMTP mail server address
				.ServerAddress = strMailServer

				'Who the e-mail is from
				.Sender = strFromEmailAddress
				.SenderName = strFromEmailName

				'Who the e-mail is sent to
				.AddRecipient strRecipientEmailAddress

				'The subject of the e-mail
				.Subject = strSubject

				'Set the e-mail body format (BodyHTML=HTML Body=Text)
				If blnHTML = True Then
					.HTMLBody = strEmailBodyMessage & strEmailBodyAppendMessage
				Else
					.Body = strEmailBodyMessage & strEmailBodyAppendMessage
				End If

				'Importance of the e-mail
				.Priority = 3

				'Send the e-mail
				If NOT strMailServer = "" Then .Execute
			End With

			'Close the server mail object
			Set objJMail = Nothing
		
		
		
		
		'******************************************
		'***   w3 JMail ver.4+ mail component  ****
		'******************************************

		'JMail ver.4+ component (this version allows authentication)
		Case "Jmail4"

			'Create the e-mail server object
			Set objJMail = Server.CreateObject("Jmail.Message")
			
			'Check to see if an error has occurred
			'If an error has occurred write an error to the page
			If Err.Number <> 0 Then Call errorMsg("An error has occurred while sending an email.<br />Please check that JMail 4 or above email component is installed on the server.", "create_JMail_4_object", "functions_send_mail.asp")
		

			With objJMail
			
				'Send SMTP Server authentication data
    				If NOT strMailServerUser = "" Then .MailServerUserName = strMailServerUser
    				If NOT strMailServerPass = "" Then .MailServerPassword = strMailServerPass

				'Who the e-mail is from
				.From = strFromEmailAddress
				.FromName = strFromEmailName

				'Who the e-mail is sent to
				.AddRecipient strRecipientEmailAddress, strRecipientName

				'The subject of the e-mail
				.Subject = strSubject

				'Set the e-mail body format (BodyHTML=HTML Body=Text)
				If blnHTML = True Then
					.ContentType = "text/html"
					.HTMLBody = strEmailBodyMessage & strEmailBodyAppendMessage
				Else
					.Body = strEmailBodyMessage & strEmailBodyAppendMessage
				End If

				'Importance of the e-mail
				.Priority = 3

				'Send the e-mail
				If NOT strMailServer = "" Then .Send(strMailServer)
			End With

			'Close the server mail object
			Set objJMail = Nothing




		'******************************************
		'*** Persits AspEmail mail component   ****
		'******************************************

		'AspEmail component
		Case "AspEmail"

			'Create the e-mail server object
			Set objAspEmail = Server.CreateObject("Persits.MailSender")
			
			'Check to see if an error has occurred
			'If an error has occurred write an error to the page
			If Err.Number <> 0 Then Call errorMsg("An error has occurred while sending an email.<br />Please check that the AspEmail email component is installed on the server.", "create_AspEmail_object", "functions_send_mail.asp")
		

			With objAspEmail
				'Out going SMTP mail server address
				.Host = strMailServer
				
				'Use SMTP Server authentication if required
		    		If strMailServerUser <> "" AND strMailServerPass <> "" Then 
					'SMTP server username and password
					.Username = strMailServerUser
					.Password = strMailServerPass
				End If

				'Who the e-mail is from
				.From = strFromEmailAddress
				.FromName = strFromEmailName

				'Who the e-mail is sent to
				.AddAddress strRecipientEmailAddress

				'The subject of the e-mail
				.Subject = strSubject

				'Set the e-mail body format (BodyHTML=HTML Body=Text)
				If blnHTML = True Then
					.IsHTML = True
				End If

				'The main body of the e-mail
				.Body = strEmailBodyMessage & strEmailBodyAppendMessage

				'Send the e-mail
				If NOT strMailServer = "" Then .Send
			End With

			'Close the server mail object
			Set objAspEmail = Nothing




		'********************************************
		'*** ServerObjects AspMail mail component ***
		'********************************************

		'AspMail component
		Case "AspMail"

		   	'Create the e-mail server object
		   	Set objAspMail = Server.CreateObject("SMTPsvg.Mailer")
		   	
		   	'Check to see if an error has occurred
			'If an error has occurred write an error to the page
			If Err.Number <> 0 Then Call errorMsg("An error has occurred while sending an email.<br />Please check that the AspMail email component is installed on the server.", "create_AspMail_object", "functions_send_mail.asp")
		

		   	With objAspMail
			   	'Out going SMTP mail server address
			   	.RemoteHost = strMailServer

			   	'Who the e-mail is from
			   	.FromAddress = strFromEmailAddress
			   	.FromName = strFromEmailName

			   	'Who the e-mail is sent to
			   	.AddRecipient " ", strRecipientEmailAddress

			   	'The subject of the e-mail
			   	.Subject = strSubject

			   	'Set the e-mail body format (BodyHTML=HTML Body=Text)
			   	If blnHTML = True Then
			    		.ContentType = "text/HTML"
			   	End If

			   	'The main body of the e-mail
			   	.BodyText = strEmailBodyMessage & strEmailBodyAppendMessage

			   	'Send the e-mail
			   	If NOT strMailServer = "" Then .SendMail
			   End With

		   	'Close the server mail object
		   	Set objAspMail = Nothing
	End Select
	
	
	'Check to see if an error has occurred
	'If an error has occurred write an error to the page
	If Err.Number <> 0 Then Call errorMsg("An error has occurred while sending an email.", "send_mail_footer", "functions_send_mail.asp")

	'Disable error trapping
	On Error goto 0


	'Set the returned value of the function to true
	SendMail = True
End Function
%>

⌨️ 快捷键说明

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