zoukankan      html  css  js  c++  java
  • AX 2009 实现outlook发送邮件并带多个附件

      做过AX的人,对outlook发送邮件都应该非常熟悉,但是,要将AX中的附加图片和文档,一起附加到outlook并发送。我觉得还是值得一说的。

      我还是以拿出代码和大家分享吧。

      void sendEmail()

      {    

        COM                         outLook;    

        COM                         item;    

        COM                         attach;    

        COM                         cc;    

        System.Net.Mail.MailAddress adrSend;    

        str                         subPath;    

        str                         strSubject;    

        str                         userid;    

        int                         i;    

        System.Text.RegularExpressions.Regex reg;    

        EmplTable    emplTable;     ;    

        userid = curuserid();    

        emplTable = EmplTable::find(EmplTable::userId2EmplId(curuserid()));    

        //reg = new System.Text.RegularExpressions.Regex("@^\s*([A-Za-z0-9_-]+(\.\w+)*@([\w-]+\.)+\w{2,3})\s*$/");     reg = new                    System.Text.RegularExpressions.Regex("^[/w-]+(/.[/w-]+)*@[/w-]+(/.[/w-]+)+$");    

        if(!reg.IsMatch(emplTable.OutlookUserID))    

        {        

          throw error("Email format is error");    

        }     //adrSend = new System.Net.Mail.MailAddress(emplTable.OutlookUserID);

           adrSend = new System.Net.Mail.MailAddress("kui.ding@rogrand.com");    

        outLook = new COM("OutLook.application");    

        item = outLook.CreateItem(0);    

        attach  = item.attachments();    

        //item.to(emplTable.OutlookUserID);    

        item.to("364991746@qq.com");    

        //item.cc("kui.ding@rogrand.com;kimding@163.com");    

        strSubject = strreplace(this.subjectText(),'\r\n','');    

        item.subject(strSubject);     //item.body("testtesttest");    

        for(i = 1;i<=conlen(this.attachPath());i++)    

        {

                if(winapi::fileExists(conpeek(this.attachPath(),i)))        

          {            

            attach.add(@""+conpeek(this.attachPath(),i));        

          }        

          else        

          {            

            info(strfmt("not exist %1",conpeek(this.attachPath(),i)));        

          }    

        }    

        item.attachments();  

          

        //item.send(); //直接发送   

        item.display(true);//显示outlook界面

    }

      刚开始做的时候,也很纠结,不知道多个附件该如何附加,后来是通过参考在.net当中outlook添加附件,才慢慢摸索出来的。

  • 相关阅读:
    钉钉内网穿透一键启动cmd脚本
    vscode的开发配置文件
    'scope' is defined but never used解决方法
    微信小程序使用echarts不跟随父元素滑动
    小程序图片开发工具能显示真机调试和体验版不显示
    Web端在线实时聊天,基于WebSocket(前后端分离)
    在vue项目中使用scss,以及vscode适配scss语法(解决使用scss语法编辑器报错)
    自动按需引入组件用不了(Vant)
    npm ERR! Unexpected end of JSON input while parsing near '...'解决方法
    div和img垂直居中的方法
  • 原文地址:https://www.cnblogs.com/dingkui/p/2567524.html
Copyright © 2011-2022 走看看