Function Sendmail(MailFromAddr, RecipientAddr, cSubject, strMsgInfo, sCc, sBcc, iPriority, RecipientName, cMailHost,cMailFromName,attachment,HTMLMail)
IF instr(strMsgInfo,"<")<>0 then ' This is HTML content
HTMLMail=true
ELSE
HTMLMail=false
END IF
On Error Resume Next
'Dimension variables
Dim objCDOSYSCon
'Create the e-mail server object
Set objCDOSYSMail = Server.CreateObject("CDO.Message")
Set objCDOSYSCon = Server.CreateObject ("CDO.Configuration")
'Set and update fields properties
'Out going SMTP server
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "localhost
'SMTP port
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
'CDO Port
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
'Timeout
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 600
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/sendusername") = "username"
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "password
objCDOSYSCon.Fields.Update
'Update the CDOSYS Configuration
Set objCDOSYSMail.Configuration = objCDOSYSCon
'Who the e-mail is from
objCDOSYSMail.From = "<" & MailFromAddr& ">"
'mail carbon copy
objCDOSYSMail.Cc = "<" & sCc & ">"
objCDOSYSMail.Bcc = "<" & sBcc & ">"
'Who the e-mail is sent to
objCDOSYSMail.To = "<" & RecipientAddr& ">"
'The subject of the e-mail
objCDOSYSMail.Subject = cSubject
If CBool( HTMLMail ) Then
objCDOSYSMail.HTMLBody = strMsgInfo
Else
objCDOSYSMail.TextBody = strMsgInfo
End If
'Send the e-mail
objCDOSYSMail.Send
'Close the server mail object
Set objCDOSYSMail = Nothing
End Function