Independentsoft
- any library, any programming language
Home
Purchase
Support
Company
Contact
Exchange Web Services .NET
>
Tutorial
> Reply to message
The following example shows you how to send reply message.
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 { IsEqualTo restriction = new IsEqualTo(MessagePropertyPath.Subject, "Test"); FindItemResponse inboxResponse = service.FindItem(StandardFolder.Inbox, restriction); for (int i = 0; i < inboxResponse.Items.Count; i++) { ItemId currentMessageId = inboxResponse.Items[i].ItemId; ReplyItem replyItem = new ReplyItem(currentMessageId); replyItem.NewBody = new Body("This is reply message body text."); ItemInfoResponse response = service.Reply(replyItem); } } 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 restriction As New IsEqualTo(MessagePropertyPath.Subject, "Test") Dim inboxResponse As FindItemResponse = service.FindItem(StandardFolder.Inbox, restriction) For i As Integer = 0 To inboxResponse.Items.Count - 1 Dim currentMessageId As ItemId = inboxResponse.Items(i).ItemId Dim replyItem As New ReplyItem(currentMessageId) replyItem.NewBody = New Body("This is reply message body text.") Dim response As ItemInfoResponse = service.Reply(replyItem) Next 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*