VFP怎样将信息发至指定QQ邮箱?
VFP怎样将信息发至指定QQ邮箱?
* 功能:邮件发送 * 参数:tcMail收件人,tcCC抄送,tcBCC密送,tcSubject主题,tcBody正文,tcAttFile附件,tcSmtp发送服务器,tcFrom发件人,tcUid用户名,tcPwd口令 FUNCTION SendMail(tcMail,tcCC,tcBCC,tcSubject,tcBody,tcAttFile,tcSmtp,tcFrom,tcUid,tcPwd) LOCAL cError,cErrMsg,m,n,i,j,k,objFields m.cErrMsg = "" m.cError = ON("ERROR") ON ERROR m.cErrMsg = MESSAGE() *服务器设置 m.objMail = CREATEOBJECT("CDO.Message") * 清除原默认配置 m.objFields = m.objMail.Configuration.Fields FOR i = 0 TO objFields.Count - 1 m.objFields.Delete(i) ENDFOR m.objFields.Update * 设置发信服务配置 m.objConf = m.objMail.Configuration m.objConf.Fields.Append("http://schemas./cdo/configuration/languagecode",2) m.objConf.Fields(0).Value = "zh-cn" m.objConf.Fields.Append("http://schemas./cdo/configuration/postusing",2) m.objConf.Fields(1).Value = 0 m.objConf.Fields.Append("http://schemas./cdo/configuration/sendemailaddress",2) m.objConf.Fields(2).Value = m.tcFrom m.objConf.Fields.Append("http://schemas./cdo/configuration/sendpassword",2) m.objConf.Fields(3).Value = m.tcPwd m.objConf.Fields.Append("http://schemas./cdo/configuration/sendusername",2) m.objConf.Fields(4).Value = m.tcUid m.objConf.Fields.Append("http://schemas./cdo/configuration/sendusing",2) m.objConf.Fields(5).Value = 2 m.objConf.Fields.Append("http://schemas./cdo/configuration/smtpaccountname",2) m.objConf.Fields(6).Value = "网易服务器" m.objConf.Fields.Append("http://schemas./cdo/configuration/smtpauthenticate",2) m.objConf.Fields(7).Value = 1 m.objConf.Fields.Append("http://schemas./cdo/configuration/smtpconnectiontimeout",2) m.objConf.Fields(8).Value = 180 m.objConf.Fields.Append("http://schemas./cdo/configuration/smtpserver",2) m.objConf.Fields(9).Value = m.tcSmtp m.objConf.Fields.Append("http://schemas./cdo/configuration/smtpserverport",2) m.objConf.Fields(10).Value = 25 m.objConf.Fields.Append("http://schemas./cdo/configuration/usemessageresponsetext",2) m.objConf.Fields(11).Value = .T. m.objConf.Fields.Append("urn:schemas:calendar:timezoneid",2) m.objConf.Fields(12).Value = 21 m.objConf.Fields.Update * 邮件设置 注:邮件地址和附件文件可以同时多个,在字符串中使用分号(;)分隔 m.objMail.To = m.tcMail && 收件人 m.objMail.CC = m.tcCC && 抄送 objMail.BCC = m.tcBCC && 密件抄送 m.objMail.Subject = m.tcSubject && 主题 m.objMail.TextBody = m.tcBody && 内容 objMail.From = m.tcFrom && 发件人(服务器要校验的) * 根据附件列表添加附件 IF !EMPTY(m.tcAttFile) m.tcAttFile = m.tcAttFile + ";" m.j = 0 m.n = OCCURS(";", m.tcAttFile) FOR m.i = 1 TO m.n m.k = AT(";", m.tcAttFile, m.i) m.cFile = SUBSTR(m.tcAttFile, m.j+1, m.k-m.j-1) IF !FILE(m.cFile) MESSAGEBOX("附件文件[" + m.cFile + "没找到!",16,"提示") ON ERROR &cError RETURN m.cErrMsg ENDIF objMail.AddAttachment(m.cFile) &&添加附件 m.j = m.k ENDFOR ENDIF * 发送邮件 m.objMail.Send ON ERROR &cError RETURN m.cErrMsg ENDFUNC以下是调用示例: