How to Retrieve and filter some lists of recipients with MailUp .NET SDK

This snippet takes advantage of the MailUp .NET SDK to setup the secure communication towards the server through OAuth2 two leg authentication.
You can start digging into the MailUP API world by reading this content:
An instance of MailUpClient class is able to manage one user at a time. 
A MailUpClient object needs a pair clientID-clientSecret, which you can retrieve following this procedure:
Then, you should login with your credentials, invoking RetrieveAccessToken(username, password) method (it should be done just only once at the beginning of the process)
Finally, you can call all the methods you want! 
E.g. to retrieve a list you should provide some filters (see the syntax here:
Copy Embed Code
<iframe id="embedFrame" style="width:600px; height:300px;"
Click on the embed code to copy it into your clipboard Width Height
Leave empty to retrieve all the content Start End
public static void GetLists(string clientID, string clientSecret, string username, string password) { // 1) Setup the MailUp Client: MailUpClient client = new MailUpClient(clientID, clientSecret); try { client.RetrieveAccessToken(username, password); } catch (MailUpException ex) { Console.WriteLine("Unable to access the service due to " + ex.Message); return; } // 2) Prepare the input: string filter = "Format.Trim().Equals('html')"; // 3) Invoke the web method: CollectionOf<ConsoleListItem> result = null; try { result = client.GetLists(filter); } catch (Exception ex) { Console.WriteLine("Cannot perform the operation due to " + ex.Message); return; } // 4) Print results: if ((result != null) && (result.Count > 0)) Console.WriteLine("Retrieved Lists:" + result.Count + "; first one with name:" + result[0].Name); else Console.WriteLine("An error occurred while retrieving the lists."); }
If you want to be updated about similar snippets, Sign in and follow our Channels

blog comments powered by Disqus