0

I need to be able to access message tracking from Exchange 2010. I would prefer to do this with some sort of api but from the research that I've done I can seem to find anything that hints to the possibility to do this through EWS. The end goal is to count the number of emails sent by account and store the numbers into a seperate business application.

Edit: After looking at the EWS wsdl it looks like there is a FindMessageTrackingReport and GetMessageTrackingReport call. These are not found in EWS Managed API. I'm not sure this is what I'm looking for but I won't know until I get the results back from the API. Is there a way that I can still call this with just a normal web service? Any examples?

cal5barton
  • 1,606
  • 1
  • 14
  • 29

2 Answers2

0

Something to the effect of this should work. I didn't have the time to import the proper namespaces, so it may not be perfect.

string querystring = "From:username@example.com Kind:email"; 
ItemView iv = new ItemView(1000);
FindItemsResults<Item> foundItems = _service.FindItems(WellKnownFolderName.SentItems, querystring, iv);
int count = foundItems.count();
mgmedick
  • 686
  • 7
  • 23
  • I've tried this before and I've run into permission issues. – cal5barton Aug 26 '14 at 23:00
  • Hmm sorry for the late reply, are you getting an exception when you try it? Are you able to use _service.FindItems() at all. Because that's pretty paramount to doing anything with EWS. – mgmedick Aug 27 '14 at 15:55
  • I can do it for the mailboxes I have permissions to but I can't search inside other's mailboxes unless I were to be granted access to their boxes which will not fly. – cal5barton Aug 27 '14 at 16:09
  • If you're trying to access the sentItems mailbox without the creditials for the user (i.e email and password), then I'm not aware of a way to do that. I've only done it when I have the email and password of the user I'm trying to access – mgmedick Aug 27 '14 at 17:55
  • If you do have that information and you're still getting permission issues with certain mailboxes for the user then maybe you need to connect to the service with impersonation. There should be a method called "ConnectToServiceWithImpersonation" located in the Exchange Authentication project that you can download. http://code.msdn.microsoft.com/Exchange-2013-101-Code-3c38582c Or you might have issue because the URL for your exchange.asmx is wrong. http://stackoverflow.com/questions/17236956/retrieving-mails-from-a-remote-exchange-server-some-sort-of-security-issue – mgmedick Aug 27 '14 at 18:07
0

I was able to finally find a solution. It wasn't through EWS but rather a combination of C#, Powershell, and Exchange Management Shell. Here is a link to the EWS Message Tracking Report solution

Community
  • 1
  • 1
cal5barton
  • 1,606
  • 1
  • 14
  • 29