CDO and ocxQmail

Sending E-mail on Microsoft IIS

The Microsoft CDO object is supported on our mail servers. The Flicks QMAIL ActiveX component has been phased out and will not be supported or available on any new production hosting servers.

Important: Never create a form that gives the user control of both the FROM and TO addresses. This means that either FROM or TO must be hard-coded into your form script. This could allow someone to use the form for spamming, and is grounds for termination of your hosting account.


Sending E-mail using the CDO Object on Microsoft IIS

Sample Code:
function sendmail(byval strto,byval strcc,byval
	strsubject, byval strbody, byval strattach)

	Dim sch, cdoConfig

	Dim ObjSendMail
	Set ObjSendMail = CreateObject("CDO.Message") 

	'on error resume next
	sch = "http://schemas.microsoft.com/cdo/configuration/" 
	Set cdoConfig = CreateObject("CDO.Configuration") 

    With cdoConfig.Fields 
        'Set CDO Port 
        .Item(sch & "sendusing") = 2

	'YOU MUST USE THIS SMTP SERVER INSTEAD OF LOCALHOST ON OLDER SERVERS and "localhost" on new servers.
	'IF THE FTP address on the server is 204.27.195.126 use localhost.
	'
        .Item(sch & "smtpserver") = "mail.infoanalytic.com" 
        .Item(sch & "smtpserverport") = 25 
        .Item(sch & "smtpconnectiontimeout") = 60 
        .update 
    End With 

    With objsendmail
        Set .Configuration = cdoConfig 
        .From = "billing@4w.com"
        .To = strTo
	.CC = strCC
	'''.BCC = "invoices@4w.com"

        .Subject = strsubject 
        .TextBody = strbody
        .AddAttachment(strattach)
	if err = 0 then
	        .Send 
		if err <> 0 then 
			errorcode = err
		end if

	else
		errorcode = err
	end if

    End With 

    Set objsendmail= Nothing 
    Set cdoConfig = Nothing 
	on error goto 0

sendmail = errorcode
response.write err.description
end function