要定义变量
&DirTo
&EmlMessage
&DirFrom
&MesSMTP
&EmlErrFlg C(1)
发送邮件功能,点击sendmail按钮,代码如下:
Event 'sendmail'
&EmlErrFlg = 'N' // flag indicates if error when sending
//
&DirTo.Address = 'send@126.com' // email of recipient 发送地址
&DirTo.Name = 'name' // name of recipient 发送名字
&EmlMessage.To.Clear()
&EmlMessage.To.Add(&DirTo)
// &DirCc.Address = &EmlCC // email of cc recipient 抄送地址
// &DirCc.Name = &EmlCCNme // name of cc recipient
// &EmlMessage.Cc.Clear()
// &EmlMessage.Cc.Add(&DirCc)
//
// &DirBcc.Address = &EmlBCC // email of Bcc recipient 密送地址
// &DirBcc.Name = &EmlBCCNme // name of Bcc recipient
// &EmlMessage.BCc.Clear()
// &EmlMessage.BCc.Add(&DirBcc)
&EmlMessage.Subject = 'subject' //主题
&EmlMessage.HTMLText = 'wangxianjun,浙江宁波人也。<br>知道吗!' //html格式内容
// Do Case
// Case &EmlMde = 'O' // outlook
//
// &OutlookMsg.Editwindow = 0 // no user intervention
//
// &OutlookMsg.Send(&EmlMessage)
//
// if &OutlookMsg.ErrCode <> 0
// &EmlErrFlg = 'Y'
// &EmlMsg = (&OutlookMsg.ErrDescription)
//
// endif
//
// Case &EmlMde = 'I' // internet SMTP/POP
&DirFrom.Address = 'your@126.com' // email of sender 发送地址
&DirFrom.Name = 'wxj' // name of sender
// &EmlMessage.From.Clear()
// &EmlMessage.From.Add(&DirFrom)
&MesSMTP.Sender = &DirFrom
&MesSMTP.Host = 'smtp.126.com' //发送smtp服务器地址
// If null( &EmlPwd ) // server doesn't requiere authorization
// &MesSMTP.Authentication = 0
// Else
&MesSMTP.Authentication = 1 // clear text authorization
&MesSMTP.UserName = 'zhanghao' //用户帐号
&MesSMTP.Password = 'mima' //用户密码
// Endif
&MesSMTP.Login()
&MesSMTP.Send( &EmlMessage )
if &MesSMTP.ErrCode <> 0
&EmlErrFlg = 'Y'
&EmlMsg = (&MesSMTP.ErrDescription)
endif
&MesSMTP.Logout()
if &EmlErrFlg = 'Y'
msg('Send error :' +&EmlMsg)
else
msg('Send Successfully!')
endif
// EndCase
EndEvent // 'sendmail'