Independentsoft
- any library, any programming language
Home
Purchase
Support
Company
Contact
Graph .NET
>
Tutorial
> List messages rules
Get all the MessageRule objects defined for the user's Inbox.
C# example
using System; using System.Collections.Generic; using System.Threading.Tasks; using Independentsoft.Graph; using Independentsoft.Graph.Mails; 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 = 100; IList
rules = await client.GetMessageRules("info@independentsoft.onmicrosoft.com", query); foreach(MessageRule rule in rules) { Console.WriteLine("Id: " + rule.Id); Console.WriteLine("DisplayName: " + rule.DisplayName); Console.WriteLine("--------------------------------------------"); } } catch (GraphException ex) { Console.WriteLine("Error: " + ex.Code); Console.WriteLine("Message: " + ex.Message); Console.Read(); } } } }
VB example
Imports Independentsoft.Graph Imports Independentsoft.Graph.Mails Imports Independentsoft.Graph.QueryOptions Namespace Sample Class Module1 Shared Sub Main(ByVal args As String()) Dim task = New Task(AddressOf Run) ' Start and wait for task to end. task.Start() Console.Read() End Sub Shared Async Sub Run() Try Dim client As GraphClient = New GraphClient() client.ClientId = "63333333-209e-454e-b7bd-55a4d201270f" client.Tenant = "independentsoft.onmicrosoft.com" client.ClientSecret = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" Dim query As Query = New Query() query.Top = 100 Dim rules As IList(Of MessageRule) = Await client.GetMessageRules("info@independentsoft.onmicrosoft.com", query) For Each rule As MessageRule In rules Console.WriteLine("Id: " & rule.Id) Console.WriteLine("DisplayName: " & rule.DisplayName) Console.WriteLine("--------------------------------------------") Next Catch ex As GraphException Console.WriteLine("Error: " + ex.Code) Console.WriteLine("Error: " + ex.Message) Console.Read() End Try End Sub End Class End Namespace
Need help? Ask our developers:
Name*
Email*
Message*