用genexus发送email

要定义变量

&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'
 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值