<%
	'********************************************************************************
	'*																				*
	'*																				*
	'********************************************************************************
	Function sendMail(sFromName, sFromEmail, sRecipientEmail, sSubject, sEmailBody)
	
		Dim objEmail
		sendMail = True
	
		If ( sOWSmtpServer <> "" ) Then
			on error resume next
			if sOWEmailComponent="persitsaspmail" then
				set objEmail 		= server.CreateObject("Persits.MailSender")
				objEmail.IsHTML    	= false ' set to true if you want to send HTML emails
				objEmail.Host 		= sOWSmtpServer 
				objEmail.From 		= sFromEmail
				objEmail.FromName 	= sFromName
				objEmail.AddAddress sRecipientEmail
				objEmail.AddReplyTo sFromEmail
				objEmail.Subject 	= sSubject
				objEmail.Body 		= sEmailBody
				on error resume next
				objEmail.Send
				set objEmail 		= Nothing
			end if
			
			if sOWEmailComponent="jmail" then
				set objEmail 		= server.CreateOBject( "JMail.Message" ) 
				objEmail.Logging 	= true
				objEmail.silent 	= true
				objEmail.From 		= sFromEmail
				objEmail.FromName 	= sFromName
				objEmail.Subject	= sSubject
				objEmail.AddRecipient sRecipientEmail
				objEmail.Body 		= sEmailBody
				on error resume next
				objEmail.send(sOWSmtpServer)
				set objEmail 		= Nothing		
			end if
			
			if sOWEmailComponent="jmailhtml" then
				set objEmail 		= server.CreateOBject( "JMail.Message" ) 
				objEmail.Logging 	= true
				objEmail.silent 	= true
				objEmail.From 		= sFromEmail
				objEmail.FromName 	= sFromName
				objEmail.Subject	= sSubject
				objEmail.AddRecipient sRecipientEmail
				objEmail.Body 		= sEmailBody
				objEmail.HTMLBody 	= "<HTML><BODY><font color=""red"">" & sOWCompany & "</font><br>"
				objEmail.appendHTML "<img src=""" & sOWStoreUrlSSL & "/owTemplates/images/" & sOWCompanyLogo & """>"
				objEmail.appendHTML "<br><br>" & sEmailBody & "</BODY></HTML>"
				on error resume next
				objEmail.send(sOWSmtpServer)  
				set objEmail 		= Nothing
			end if
			
			if sOWEmailComponent="serverobjectsaspmail1" then
				set objEmail 			= Server.CreateObject("SMTPsvg.Mailer")
				objEmail.RemoteHost 	= sOWSmtpServer
				objEmail.FromName    	= sFromName
				objEmail.FromAddress 	= sFromEmail
				objEmail.AddRecipient sRecipientEmail, sRecipientEmail
				objEmail.Subject     	= sSubject
				objEmail.BodyText    	= sEmailBody
				on error resume next
				objEmail.SendMail
				set objEmail 			= Nothing
			end if
			
			if sOWEmailComponent="cdonts" then
				Set objEmail 	 	= Server.CreateObject ("CDONTS.NewMail")
				objEmail.BodyFormat = 1
				objEmail.MailFormat = 0
				on error resume next 
				objEmail.Send sFromEmail, sRecipientEmail, sSubject, sEmailBody
				set objEmail 		= Nothing
			end if
			
			if sOWEmailComponent="cdo" then
				Set objEmail 		= server.CreateObject("CDO.Message")
				objEmail.From 		= sFromEmail
				objEmail.To 		= sRecipientEmail
				objEmail.Subject 	= sSubject
				objEmail.textBody 	= sEmailBody
				on error resume next
				objEmail.Send
				objEmail.Send sFromEmail, sRecipientEmail, subject, body
				Set objEmail 		= Nothing
			end if
			
			if sOWEmailComponent="cdontshtml" then
				HTML = ""
				HTML = HTML & "<HTML>"
				HTML = HTML & "<HEAD>"
				HTML = HTML & "<TITLE>" & sOWCompany & "</TITLE>"
				HTML = HTML & "</HEAD>"
				HTML = HTML & "<BODY  bgcolor=""lightyellow"">"
				HTML = HTML & "<TABLE cellpadding=""4"">"
				HTML = HTML & "<TR><TH><FONT color=""darkblue""  SIZE=""4"">"  
				HTML = HTML & subject & "</FONT></TH></TR>" 
				HTML = HTML & "<TR><TD>"
				HTML = HTML & sEmailBody
				HTML = HTML & "</FONT></TD></TR></TABLE><BR><BR>"
				HTML = HTML & "</BODY>"
				HTML = HTML & "</HTML>"
				
				set objEmail 		= Server.CreateObject("CDONTS.NewMail")     
				objEmail.From   	= sFromEmail
				objEmail.Subject	= sSubject
				objEmail.To     	= sRecipientEmail
				objEmail.BodyFormat = 0 
				objEmail.MailFormat = 0 
				objEmail.Body 	    = HTML
				objEmail.Send
				set objEmail		= nothing
			end if
			
			if sOWEmailComponent="bamboosmtp" then
				set objEmail 		= Server.CreateObject("Bamboo.SMTP") 
				objEmail.Server 	= sOWSmtpServer
				objEmail.Rcpt 		= sRecipientEmail 
				objEmail.From 		= sFromEmail
				objEmail.FromName 	= sFromName 
				objEmail.Subject 	= sSubject
				objEmail.Message 	= sEmailBody 
				on error resume next 
				objEmail.Send 
				set objEmail 		= nothing 
			end if
			
			if sOWEmailComponent="ocxmail" then
				set objEmail = Server.CreateObject("ASPMAIL.ASPMailCtrl.1") 
				on error resume next 
				objEmail.SendMail sOWSmtpServer, sRecipientEmail, sFromEmail, sSubject, sEmailBody 
			end if       
			
			if sOWEmailComponent="dundasmail" then
				set objEmail 			= Server.CreateObject("Dundas.Mailer")     
				objEmail.TOs.Add sRecipientEmail
				objEmail.FromAddress	= sFromEmail
				objEmail.Subject 		= sSubject 
				objEmail.SMTPRelayServers.Add sOWSmtpServer
				objEmail.Body 			= sEmailBody
				objEmail.SendMail
				Set objEmail 			= Nothing 
			end if
			
			if sOWEmailComponent="aspsmartmail" then
				set objEmail 			= Server.CreateObject("aspSmartMail.SmartMail")
				objEmail.Server 		= sOWSmtpServer
				objEmail.SenderName 	= sFromName
				objEmail.SenderAddress 	= sFromEmail
				objEmail.Recipients.Add sRecipientEmail,""
				objEmail.Subject 		= sSubject
				objEmail.Body 			= sEmailBody
				objEmail.SendMail
				set objEmail			=Nothing
			end if
			
			if err <> 0 then  
				%>
				<html> 
					<br><br>
					<%=LANG_DT( "IEMAIL_ERROR", "Error while sending email" )%>:  <%=Err.Description%>. 
					<%=LANG_DT( "IEMAIL_CHECKCOMPONENT", "Please check that an email component has been correctly installed and configured. To hide this message, please disable Email Debugging within the Configurations menu." )%>
					<hr>
					<br><%=LANG_DT( "IEMAIL_FROM", "From" )%>    : <%=sFromEmail%>    
					<br><%=LANG_DT( "IEMAIL_TO", "To" )%>      : <%=sRecipientEmail%>
					<br><%=LANG_DT( "IEMAIL_SUBJECT", "Subject" )%> : <%=sSubject%>
					<br><%=LANG_DT( "IEMAIL_BODY", "Body" )%>    : <%=sEmailBody%>        
				</html>
				<%
				sendMail = False
			end if
		End If
	
	End Function
	'********************************************************************************
%>