import com;

sendMail = function(mfrom,rcpt,sbj,tbody,serverIP,attachfile) {
	//Use external smtp server to send mail
	if(!rcpt or !mfrom)
   	return;
   	
	if( ..string.trim(rcpt) == "" or ..string.trim(mfrom) == "" )
   	return;
	
 	
	var objEmail = com.CreateObject("CDO.Message")
	objEmail.From = mfrom
	objEmail.To = rcpt
	//objEmail.Cc = cc
	//objEmail.Bcc = bcc
	objEmail.Subject = sbj
	objEmail.Textbody = tbody
	//Sending an HTML e-mail:
	//objEmail.HTMLBody = "This is a message."
	//Sending an HTML e-mail that sends a webpage from a website:
	//objEmailCreateMHTMLBody "file://c:/mydocuments/test.htm"
	if( attachfile && string.trim(attachfile) != "" )
       	objEmail.AddAttachment( attachfile )
    
	objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing").Value = 2
	objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver").Value = serverIP
	objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport").Value = 25
	//------Type of authentication, NONE, Basic (Base64 encoded), NTLM--------
	//objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate").Value = cdoBasic
	//-------Your UserID/Passwd on the SMTP server for SMTP auth for mail sent-----
	//objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername").Value = "USER_NAME"
	//objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword").Value = "PASSWORD"
	//-------Use SSL for the connection (false or true)---------
	//objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl").Value = false
	//Connection Timeout in seconds (the maximum time CDO will try to establish a
	//--------connection to the SMTP server)---------
	//objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout").Value = 60
	
	objEmail.Configuration.Fields.Update()
	objEmail.Send()
	objEmail=null
}

发件人="web@ecranesoft.com"
收件人="admin@ecranesoft.com, hi@ecranesoft.com" 
邮件服务器="smtp.qq.com"
标题="标题"
内容="邮件内容"

sendMail(发件人,收件人,标题,内容,邮件服务器 )
