Independentsoft
- any library, any programming language
Home
Purchase
Support
Company
Contact
Graph .NET
>
Tutorial
> Append message body
The following example shows you how to append (update) message body text.
C# example
using System; using System.Collections.Generic; using System.Threading.Tasks; using Independentsoft.Graph; using Independentsoft.Graph.Mails; using Independentsoft.Graph.Users; using Independentsoft.Graph.QueryOptions; namespace ConsoleApp1 { class Program { static async Task Main() { try { GraphClient client = new GraphClient(); client.ClientId = "63333333-209e-454e-b7bd-55a4d201270f"; client.Tenant = "independentsoft.onmicrosoft.com"; client.ClientSecret = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; Query query = new Query(); query.Top = 999; IList
messages = await client.GetMessages(StandardMailboxFolder.Inbox, new UserId("info@independentsoft.onmicrosoft.com"), query); for (int i = 0; i < messages.Count; i++) { Console.WriteLine("Id = " + messages[i].Id); Console.WriteLine("Subject = " + messages[i].Subject); if(messages[i].Body == null) { messages[i].Body = new ItemBody("New message body.", ContentType.Text); } else if (messages[i].Body != null && messages[i].Body.ContentType == ContentType.Text) { messages[i].Body.Content = messages[i].Body.Content + " appended message body"; } else if (messages[i].Body != null && messages[i].Body.ContentType == ContentType.Html) { messages[i].Body.Content = messages[i].Body.Content.Replace("