by
0
6
1,600
16
Top 1% !
Famous
Easy-to-find
Specified
Tuned
OpenSource
Popularity: 19279th place

Published on:

AreaCommonUseCases
Extension.cs
InputName0clientID
InputName1clientSecret
InputName2username
InputName3password
InputType0string
InputType1string
InputType2string
InputType3string
LanguageCSharp
Languagenimrod
LicenseMIT_X11
MethodNameSubscribeContactWithCOI
OSWindows
OutputTypevoid

MailUp REST API - How to subscribe a single contact with the "Confirmed Optin" Procedure

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: http://help.mailup.com/display/mailupapi/REST+API
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: http://help.mailup.com/display/mailupapi/Authenticating+with+OAuth+v2
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. the subscription of a contact with confirmed optin puts the contact in a pending status, and sends an email to this contact with an activation link. After following this link, the contact is finally active.
Copy Embed Code
<iframe id="embedFrame" style="width:600px; height:300px;"
src="https://www.snip2code.com/Embed/300490/MailUp-REST-API---How-to-subscribe-a-sin?startLine=0"></iframe>
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 SubscribeContactWithCOI(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: int idList = 1; ConsoleRecipientItem recipient = new ConsoleRecipientItem() { Email = "test1COI@mailup.com", Name = "First COI New Recipient" + DateTime.Now.ToFileTimeUtc(), Fields = new List<ConsoleRecipientDynamicFieldItem>() { new ConsoleRecipientDynamicFieldItem() { Id = 1, Value = "Name1COI_" + DateTime.Now.ToFileTimeUtc() }, new ConsoleRecipientDynamicFieldItem() { Id = 2, Value = "LastName1COI_" + DateTime.Now.ToFileTimeUtc() } //here you can add all the fields you want to add... } }; // 3) Invoke the web method: int result = 0; try { result = client.AddRecipientToList(idList, recipient, true); } catch (Exception ex) { Console.WriteLine("Cannot perform the operation due to " + ex.Message); return; } // 4) Print results: if (result > 0) Console.WriteLine("Recipients Added with confirmed Opt-in! The ID of the recipient is " + result); else Console.WriteLine("An error occurred while adding the recipients with confirmed Opt-in."); }
If you want to be updated about similar snippets, Sign in and follow our Channels

blog comments powered by Disqus