Independentsoft
- any library, any programming language
Home
Purchase
Support
Company
Contact
Exchange Web Services .NET
>
Tutorial
> Find message tracking report
The following example shows you how to find message tracking report.
C# example
using System; using System.Net; using Independentsoft.Exchange; namespace Sample { class Program { static void Main(string[] args) { NetworkCredential credential = new NetworkCredential("username", "password"); Service service = new Service("https://myserver/ews/Exchange.asmx", credential); try { Mailbox mailbox = new Mailbox("John@mydomain.com"); FindMessageTrackingReportResponse response = service.FindMessageTrackingReport(MessageTrackingScope.Organization, "mydomain.com", mailbox); foreach (MessageTrackingSearchResult result in response.MessageTrackingSearchResults) { Console.WriteLine("Subject=" + result.Subject); if (result.Sender != null) { Console.WriteLine("Sender=" + result.Sender.EmailAddress); } if (result.Sender != null) { Console.WriteLine("PurportedSender=" + result.PurportedSender.EmailAddress); } Console.WriteLine("PreviousHopServer=" + result.PreviousHopServer); Console.WriteLine("MessageTrackingReportId=" + result.MessageTrackingReportId); Console.WriteLine("SubmittedTime=" + result.SubmittedTime); foreach (Mailbox recipient in result.Recipients) { Console.WriteLine("Recipient=" + recipient.EmailAddress); } Console.WriteLine("-----------------------------------------------"); } Console.Read(); } catch (ServiceRequestException ex) { Console.WriteLine("Error: " + ex.Message); Console.WriteLine("Error: " + ex.XmlMessage); Console.Read(); } catch (WebException ex) { Console.WriteLine("Error: " + ex.Message); Console.Read(); } } } }
VB example
Imports System Imports System.Net Imports Independentsoft.Exchange Namespace Sample Class Module1 Shared Sub Main(ByVal args As String()) Dim credential As New NetworkCredential("username", "password") Dim service As New Service("https://myserver/ews/Exchange.asmx", credential) Try Dim mailbox As New Mailbox("John@mydomain.com") Dim response As FindMessageTrackingReportResponse = service.FindMessageTrackingReport(MessageTrackingScope.Organization, "mydomain.com", mailbox) For Each result As MessageTrackingSearchResult In response.MessageTrackingSearchResults Console.WriteLine("Subject=" & result.Subject) If result.Sender IsNot Nothing Then Console.WriteLine("Sender=" & result.Sender.EmailAddress) End If If result.Sender IsNot Nothing Then Console.WriteLine("PurportedSender=" & result.PurportedSender.EmailAddress) End If Console.WriteLine("PreviousHopServer=" & result.PreviousHopServer) Console.WriteLine("MessageTrackingReportId=" & result.MessageTrackingReportId) Console.WriteLine("SubmittedTime=" & result.SubmittedTime) For Each recipient As Mailbox In result.Recipients Console.WriteLine("Recipient=" & recipient.EmailAddress) Next Console.WriteLine("-----------------------------------------------") Next Console.Read() Catch ex As ServiceRequestException Console.WriteLine("Error: " + ex.Message) Console.WriteLine("Error: " + ex.XmlMessage) Console.Read() Catch ex As WebException Console.WriteLine("Error: " + ex.Message) Console.Read() End Try End Sub End Class End Namespace
Need help? Ask our developers:
Name*
Email*
Message*