zoukankan      html  css  js  c++  java
  • 通过ADO删除Exchange 中邮件的办法

    1.启动 Microsoft Visual Studio.net,新建一个项目

    2.添加COM 引用Microsoft ActiveX Data Object 2.5 Libary

    3:示例

    try
    {
    ADODB.Connection oCn
    = new ADODB.Connection();
    ADODB.Recordset oRs
    = new ADODB.Recordset();

    ADODB.Fields oFields;
    ADODB.Field oField;

    // TODO: Replace the folder URL with your folder URL.
    string sFdUrl = "http://ExchServer/exchange/UserAlias/Inbox";

    oCn.Provider
    = "exoledb.datasource";
    oCn.Open(sFdUrl,
    "", "", -1);


    string strSql;
    strSql
    = "";
    strSql
    = "select ";
    strSql
    = strSql + " \"urn:schemas:mailheader:content-class\"";
    strSql
    = strSql + ", \"DAV:href\" ";
    strSql
    = strSql + ", \"DAV:displayname\"";
    strSql
    = strSql + " from scope ('shallow traversal of " + "\"";
    strSql = strSql + sFdUrl + "\"') ";
    strSql = strSql + " WHERE \"DAV:ishidden\" = false";
    strSql
    = strSql + " AND \"DAV:isfolder\" = false";
    //TODO: Replace 'Test.eml' with the name of the mail that you want to delete.
    strSql = strSql + " AND \"DAV:displayname\" = 'Test.eml'";


    oRs.Open(strSql, oCn,
    ADODB.CursorTypeEnum.adOpenUnspecified,
    ADODB.LockTypeEnum.adLockOptimistic,
    1);

    Console.WriteLine(oRs.RecordCount);

    oRs.MoveFirst();
    while(!oRs.EOF)
    {

    oFields
    = oRs.Fields;

    oField
    = oFields["DAV:href"];
    Console.WriteLine(oField.Value);

    oField
    = oFields["DAV:displayname"];
    Console.WriteLine(oField.Value);
    oRs.Delete(ADODB.AffectEnum.adAffectCurrent);

    oRs.MoveNext();
    Console.WriteLine(
    "Item Deleted");
    Console.WriteLine(
    "--------------------------");

    }

    oCn.Close();

    oCn
    = null;
    oField
    = null;
    oFields
    = null;
    }
    catch (Exception e)
    {
    Console.WriteLine(
    "{0} Exception caught.", e);
    }
  • 相关阅读:
    tomcat安装
    卸载重安firefox
    Metasploit笔记之信息收集命令
    postgresql-9.0.18-1-linux.run启动
    ubuntu 安装自启动管理
    MySQL数据库”mysql SQL Error:1146,SQLState:42S02 “解决方法
    PE笔记之节表
    标准类型String(学习中)
    链表实现(打印元素的实现)
    C++中new和delete来创建和释放动态数组
  • 原文地址:https://www.cnblogs.com/wudingfeng/p/1619415.html
Copyright © 2011-2022 走看看