zoukankan      html  css  js  c++  java
  • 通过COM发送邮件而不跳出安全警告

     1 void EmailExtendedMAPISendMail()//不会跳出安全警告框,嘿嘿
     2 {
     3     MapiEx              mapiEx;
     4     MapiExMail          mapiExMail;
     5     boolean             mapiInitialised;
     6     COM                 outlookNameSpace;
     7     COM                 outlook;
     8     COM                 folder;
     9     COM                 item;
    10     str                 entryId;
    11     str                 storeId;
    12     InteropPermission   permission;
    13     List                List = new List(types::String);
    14     ListEnumerator      Le;
    15 
    16     #define.outlookapplication("outlook.application")
    17     #define.mapi("mapi")
    18     #smmMSOutlook2002ObjectModelConstants
    19 ;
    20     FromVendStr = FromVendor.valueStr();
    21     ToVendStr   = ToVendor.valueStr();
    22     SubjectStr  = Subject.valueStr();
    23     BCCEmailStr = BCC.valueStr();
    24     HtmlbodyStr = Htmlbody.valueStr();
    25 
    26     List = global::strSplit(BCCEmailStr,";");
    27     Le   = List.getEnumerator();
    28 
    29     permission       = new InteropPermission(InteropKind::ComInterop);
    30     permission.assert();
    31 
    32     outlook          = new COM (#outlookapplication);
    33     outlookNameSpace = outlook.getNameSpace(#mapi);
    34 
    35     outlookNameSpace.logon();
    36     folder  = outlookNameSpace.getDefaultFolder(#olFolderInbox);
    37     storeId = folder.storeId();
    38     item    = outlook.createItem(#olMailItem);
    39 
    40     if(item)
    41     {
    42         item.subject(SubjectStr);
    43         item.body(HtmlbodyStr);
    44 
    45         item.saveSentMessageFolder(outlookNameSpace.getDefaultFolder(#olFolderSentMail));
    46         item.save();
    47         entryId = item.entryId();
    48 
    49         mapiEx = new MapiEx();
    50 
    51         if(mapiEx && mapiEx.mapiInitialised())
    52         {
    53             mapiInitialised = true;
    54             if (!mapiEx.logon("","",0) || !mapiEx.openMessageStore(storeId))
    55             {
    56                 mapiInitialised = false;
    57                 mapiEx.logout();
    58                 mapiEx.finalize();
    59                 return;
    60             }
    61 
    62             mapiExMail = mapiEx.getMailFromEntryId(entryId);
    63 
    64             if (mapiExMail)
    65             {
    66                 // mapiExMail.addRecipient('TylerL@qvsglobal.com.cn',"",#olBCC);// olTo olCC olBCC
    67                 while(Le.moveNext())
    68                 {
    69                     info(Le.current());
    70                     mapiExMail.addRecipient(Le.current(),"",#olBCC);// olTo olCC olBCC
    71                 }
    72             }
    73 
    74             mapiExMail.send();
    75             mapiExMail.close();
    76         }
    77     }
    78     if (mapiInitialised)
    79     {
    80         mapiEx.logout();
    81         mapiEx.finalize();
    82     }
    83 }
  • 相关阅读:
    Django学习(二) Django框架简单搭建
    Django学习(一) Django安装配置
    Python学习(一) Python安装配置
    注册第一天,纪念一下
    小程序笔记
    详解HTML5中的进度条progress元素简介及兼容性处理
    服务管理
    yum
    管道,输出,管道,重定向,grep
    VIM
  • 原文地址:https://www.cnblogs.com/Jinnchu/p/2767491.html
Copyright © 2011-2022 走看看