C# Exchange ActiveSync Client
Asked Answered
P

3

6

Does anyone know of any good libraries for implementing the Exchange ActiveSync Protocol into a C# Application so that I can sync emails with the application to a server (such as m.google.com)?

Porterfield answered 31/12, 2011 at 14:24 Comment(2)
Are you looking for push support? Or just trying to sync between an email account? Because Gmail also offers POP3 and IMAP support and both are supported in the .NET framework.Arrivederci
the IMAP that gmail uses is sadly not synchronising properly. I can delete an email on my phone, but it does not update that on outlook. Its not just for the push support, but to get hotmail to play nicely.Porterfield
V
2

There's a EAS-guide on MSDN that basically implements a Client in C#.

The main body of the protocol is described in MS-ASCMD.

Vitreous answered 17/9, 2012 at 9:46 Comment(0)
V
1

No. ActiveSync is licensed by Microsoft, and per terms of the license you must not release open source code. Google turned the license around on Microsoft and implemented ActiveSync themselves "to test compatibility locally."

Vulnerary answered 6/3, 2012 at 19:4 Comment(0)
S
0

Here is a partial answer from the Microsoft documentation showing how to implement the ActiveSync WBXML protocol and the ActiveSync HTTP protocol:

// 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);

If you visit the link to the documentation above be sure to check the left side navigation for additional articles on the topic. All that being said, it is recommended that you use EWS instead of ActiveSync, it should be much easier to work with.

Saiga answered 13/1, 2022 at 19:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.