【问题标题】:C# Exchange ActiveSync ClientC# Exchange ActiveSync 客户端
【发布时间】:2012-01-31 02:20:21
【问题描述】:

有没有人知道任何用于在 C# 应用程序中实现 Exchange ActiveSync 协议的好库,以便我可以将电子邮件与应用程序同步到服务器(例如 m.google.com)?

【问题讨论】:

  • 您在寻找推送支持吗?或者只是尝试在电子邮件帐户之间同步?因为 Gmail 还提供 POP3 和 IMAP 支持,并且两者都在 .NET 框架中得到支持。
  • gmail 使用的 IMAP 很遗憾没有正确同步。我可以在手机上删除电子邮件,但它不会在 Outlook 上更新。它不仅仅是为了推送支持,而是为了让 hotmail 玩得更好。

标签: c# client exchange-server activesync


【解决方案1】:

没有。 ActiveSync 由 Microsoft 许可,根据许可条款,您不得发布开源代码。谷歌在微软身上扭转了许可证,并自己实施了 ActiveSync,“以测试本地兼容性。”

【讨论】:

    【解决方案2】:

    MSDN 上有一个 EAS 指南,基本上实现了Client in C#

    协议主体描述在MS-ASCMD

    【讨论】:

      【解决方案3】:

      这是来自Microsoft documentation 的部分答案,展示了如何实现 ActiveSync WBXML 协议和 ActiveSync HTTP 协议:

      // Create credentials for the user
      NetworkCredential cred = new NetworkCredential("contoso\\deviceuser", "password");
      
      //Initialize the OPTIONS request
      ASOptionsRequest optionsRequest = new ASOptionsRequest();
      optionsRequest.Server = "mail.contoso.com";
      optionsRequest.UseSSL = true;
      optionsRequest.Credentials = cred;
      
      // Send the request
      ASOptionsResponse optionsResponse = optionsRequest.GetOptions();
      
      Console.WriteLine("Supported Versions: {0}", optionsResponse.SupportedVersions);
      Console.WriteLine("Highest Supported Version: {0}", optionsResponse.HighestSupportedVersion);
      Console.WriteLine("Supported Commands: {0}", optionsResponse.SupportedCommands);
      
      // Initialize the command request
      ASCommandRequest commandRequest = new ASCommandRequest();
      commandRequest.Command = "Provision";
      commandRequest.Credentials = cred;
      commandRequest.DeviceID = "TestDeviceID";
      commandRequest.DeviceType = "TestDeviceType";
      commandRequest.ProtocolVersion = "14.1";
      commandRequest.Server = "mail.contoso.com";
      commandRequest.UseEncodedRequestLine = true;
      commandRequest.User = "deviceuser";
      commandRequest.UseSSL = true;
      
      // Create the XML payload
      StringBuilder xmlBuilder = new StringBuilder();
      xmlBuilder.Append("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
      xmlBuilder.Append("<Provision xmlns=\"Provision:\" xmlns:settings=\"Settings:\">");
      xmlBuilder.Append("    <settings:DeviceInformation>");
      xmlBuilder.Append("        <settings:Set>");
      xmlBuilder.Append("            <settings:Model>Test 1.0</settings:Model>");
      xmlBuilder.Append("            <settings:IMEI>012345678901234</settings:IMEI>");
      xmlBuilder.Append("            <settings:FriendlyName>My Test App</settings:FriendlyName>");
      xmlBuilder.Append("            <settings:OS>Test OS 1.0</settings:OS>");
      xmlBuilder.Append("            <settings:OSLanguage>English</settings:OSLanguage>");
      xmlBuilder.Append("            <settings:PhoneNumber>555-123-4567</settings:PhoneNumber>");
      xmlBuilder.Append("            <settings:MobileOperator>My Phone Company</settings:MobileOperator>");
      xmlBuilder.Append("            <settings:UserAgent>TestAgent</settings:UserAgent>");
      xmlBuilder.Append("        </settings:Set>");
      xmlBuilder.Append("    </settings:DeviceInformation>");
      xmlBuilder.Append("     <Policies>");
      xmlBuilder.Append("          <Policy>");
      xmlBuilder.Append("               <PolicyType>MS-EAS-Provisioning-WBXML</PolicyType> ");
      xmlBuilder.Append("          </Policy>");
      xmlBuilder.Append("     </Policies>");
      xmlBuilder.Append("</Provision>");
      commandRequest.XmlString = xmlBuilder.ToString();
      
      // Send the request
      ASCommandResponse commandResponse = commandRequest.GetResponse();
      
      Console.WriteLine("XML Response: {0}", commandResponse.XmlString);
      

      如果您访问上述文档的链接,请务必查看左侧导航以获取有关该主题的其他文章。综上所述,建议您使用EWS 而不是 ActiveSync,它应该更容易使用。

      【讨论】:

        猜你喜欢
        • 2012-02-05
        • 1970-01-01
        • 1970-01-01
        • 2011-08-27
        • 2013-06-07
        • 2020-07-30
        • 1970-01-01
        • 2011-05-01
        • 2012-09-14
        相关资源
        最近更新 更多