Are you looking for customized advices? Click here to contact the expert!
by
0
5
2,227
12
Top 1% !
Famous
Easy-to-find
Refined
OpenSource
Popularity: 11281st 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 that follows a template

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 TemplateDTO 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/498950/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 SendTemplate() { // 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: TemplateDTO msg = new TemplateDTO() { TemplateId = 694, Subject = "Test message from template", 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 = null, User = new SmtpUserDTO() { Username = smtpplus_username, Secret = smtpplus_password } }; // 4) Invoke the web method: SendResponseDTO result = null; try { result = client.SendTemplate(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 template."); }
If you want to be updated about similar snippets, Sign in and follow our Channels

blog comments powered by Disqus