回复 6楼 pjtyzyq
我的代码在办公室电脑上,我参考的是下面这段代码。
#define USERNAME \'your name\' && 这里填你登录的账号
#define MAILPASSWORD \'your pass\' && 这里填你登录的口令
#define MAILFROM USERNAME + \'@\' && 这里填你邮箱后缀
#define MAILTO MAILFROM
#define MAILACCOUNT MAILFROM
TRY
m.oMsg = NEWOBJECT( \'CDO.Message\' )
CATCH
m.oMsg = NULL
ENDTRY
IF ISNULL( m.oMsg )
MESSAGEBOX( \'无法创建邮件对象!\', 16, \'错误\' )
RETURN .F.
ENDIF
m.oConfg = NEWOBJECT( \'CDO.Configuration\' )
m.oFields = m.oConfg.Fields
m.cSchemas = \'http://schemas.\'
WITH m.oFields
.item( m.cSchemas + \'sendusing\' ) = 2
.item( m.cSchemas + \'smtpserverport\' ) = 25
.item( m.cSchemas + \'smtpaccountname\' ) = MAILFROM
.item( m.cSchemas + \'sendusername\' ) = MAILACCOUNT
.item( m.cSchemas + \'sendpassword\' ) = MAILPASSWORD
.item( m.cSchemas + \'smtpauthenticate\' ) = 1
.item( m.cSchemas + \'languagecode\' ) = 0x0804
.item( m.cSchemas + \'smtpserver\' ) = \'smtp.\'
.Update()
ENDWITH
m.oMsg.Configuration = m.oConfg
WITH m.oMsg
.Subject = \'客户端软件升级报告\'
.From = MAILFROM
.To = MAILTO
.TextBody = \'客户端软件升级报告\'
AA = SYS(5) + SYS(2003) + \'\\datasetup.ini\' &&附件地址及名称
.ADDATTACHMENT(AA)
ENDWITH
TRY
m.oMsg.Send()
m.cMsg = \'邮件已发送.\'
m.oErr = NULL
CATCH TO m.oErr
TEXT TO m.cMsg NOSHOW TEXTMERGE
邮件发送失败!
<<oErr.Message>>
ENDTEXT
ENDTRY
STORE NULL TO m.oConfog, m.oMsg
MESSAGEBOX( m.cMsg )