Are you looking for customized advices? Click here to contact the expert!
by
0
5
1,668
45
Top 1% !
Famous
Tagged
Refined
OpenSource
Popularity: 20459th place
Created
Modified Aug 29, 2018

Published on:

.NETFramework4.0
Architecturex86_64
AreaTransactionalAPI
Extension.cs
LanguageCSharp
LicenseMIT_X11
OSWindows
Windows VersionWindows7

MailUp REST API - How to send a transactional email message

This snippet takes advantage of the MailUp .NET SDK to setup the secure communication towards the server.
The credentials of the SMTP+ user are passed as parameter in the body of the request.
Explore the MessageDTO object in order to understand how you can customize the message you want to send.
Copy Embed Code
<iframe id="embedFrame" style="width:600px; height:300px;"
src="https://www.snip2code.com/Embed/498949/MailUp-REST-API---How-to-send-a-transact?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 SendMessage() { // 1) Required values string username = "<your_username>"; string password = "<your_password>"; string clientid = "<your_clientid>"; string clientsecret = "<your_clientsecret>"; string smtpplus_username = "<your_smtpplus_username>"; string smtpplus_password = "<your_smtpplus_password>"; // 2) Setup the MailUp Client: MailUpClient client = new MailUpClient(clientid, clientsecret); client.RetrieveAccessToken( username, password ); // 3) prepare the input: MessageDTO msg = new MessageDTO() { Html = new HtmlDTO() { Body = "<div>Hello Mr. [firstname][lastname] !!!</div><br><img width='600' height='397' src='cid:img001'>", BodyTag = "<body>" }, Text = "Hello world!!!", Subject = "Hello friend!", From = new EmailAddressDTO() { Name = "Test User", Email = "test@mailup.it" }, To = new List<EmailAddressDTO>() { new EmailAddressDTO() { Name = "Massimo", Email = "info@mailup.it" } }, Cc = new List<EmailAddressDTO>(), Bcc = new List<EmailAddressDTO>(), ReplyTo = null, CharSet = "utf-8", ExtendedHeaders = null, Attachments = null, EmbeddedImages = new List<MessagePartDTO>() { new MessagePartDTO() { Filename = "Image.jpg", ContentId = "img001", Body = new byte[] { 0x01, 0x02, 0x03, 0x04 } } }, XSmtpAPI = new XSmtpAPIDTO() { CampaignName = "Test Campaign", CampaignCode = "1001", Header = null, Footer = null, ClickTracking = null, ViewTracking = null, Priority = null, Schedule = null, DynamicFields = new List<NameValueDTO>() { new NameValueDTO() { N = "firstname", V = "Mario"}, new NameValueDTO() { N = "lastname", V = "Rossi"} }, CampaignReport = null, SkipDynamicFields = null }, User = new SmtpUserDTO() { Username = smtpplus_username, Secret = smtpplus_password } }; // 4) Invoke the web method: SendResponseDTO result = null; try { result = client.SendMessage(msg); } catch (Exception ex) { Console.WriteLine("Cannot perform the operation due to " + ex.Message); return; } // 5) Print results: if (result != null) Console.WriteLine("Result of sending task:" + result.Message); else Console.WriteLine("An error occurred while sending message."); }
If you want to be updated about similar snippets, Sign in and follow our Channels

blog comments powered by Disqus