-1

I’m working on an application that must read the email content and move emails from one folder to another, these are the only two features that it must support. The mail server is Exchange 2010 and I have enough privileges to access the mailbox.

I’ve been seeing some posts about EWS Managed Code but I’m certainly lost in all this information. Can you shed some light on this and advise about the best approach to accomplish it?

Ps. Using VS 2015 and .net framework 4.5

Update: find below a quick test using the EWS Manage API

ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2013);
//This will accept all certificates, regardless of why they are invalid
ServicePointManager.ServerCertificateValidationCallback = (sender, certificate, chain, sslPolicyErrors) => true;
service.Credentials = new WebCredentials("Administrator", "mypassword", "myexchangeserver.com");
service.Url = new Uri("https://myexchangeserver.com/EWS/Exchange.asmx");

EmailMessage email = new EmailMessage(service);
email.ToRecipients.Add("userid@myexchangeserver.com");
email.Subject = String.Format("HelloWorld at {0}", DateTime.Now);
email.Body = new MessageBody("This is the first email I've sent by using the EWS Managed API.");
email.Send();
m0dest0
  • 849
  • 4
  • 17
  • 36

1 Answers1

0

I’m working on an application that must read the email content and move emails from one folder

Okay so you will need to use a Exchange Mailbox API to access Mailbox content, on Exchange 2010 the available API's that you could use to move a Message between folders would be MAPI (via the Outlook Object Model or Thirdparty library like Redemption) or Exchange Web Services (EWS). (other API's like POP,IMAP and Activesync would also work but are much harder to use).

To work out which is the best API to use you need to consider where your application is going to run eg if you building an code that run within outlook then using the OOM. If you building an application that is going to run on the server then use EWS.

I’ve been seeing some posts about EWS Managed Code but I’m certainly lost in all this information.

If your going to write and EWS app then using the Managed API is the best way to go, the best place is to jump into write some actual code eg start with

https://msdn.microsoft.com/en-us/library/office/dn567668(v=exchg.150).aspx

then try

https://msdn.microsoft.com/en-us/library/office/dn600291(v=exchg.150).aspx

Cheers Glen

Glen Scales
  • 20,495
  • 1
  • 20
  • 23
  • thanks, I was able to run a quick test sending an email (see above), just two things, (1) if I run the app on the server it does not need to override the SSL Cert verification, it only is required when I run it from my computer which is in domain by the way. (2) this app is going to be critical and must be running 24/7, considering this you think EWS Managed API is the better approach? thanks again Glen! – m0dest0 Jan 22 '16 at 01:48
  • 1
    (1) Why are using Self signed certificates in the first place but pretty trivial either way (2) yes if its going to be a server application use EWS. – Glen Scales Jan 22 '16 at 02:00
  • It is going to run on a server but not the Exchange Server, even in this case I should use EWS rather than EWS Managed API? – m0dest0 Jan 22 '16 at 03:39