public SendResponse RunExample() { var message = new BasicMessage(); message.Subject = "Sending A Test Message"; message.HtmlBody = "<html>This is the Html Body of my message.</html>"; message.PlainTextBody = "This is the Plain Text Body of my message."; message.From.Email = "*****@*****.**"; message.ReplyTo.Email = "*****@*****.**"; message.To.Add("!@#$!@#$!@#$@#!$"); message.To.Add("failure.com"); message.To.Add("ImMissingSomething"); message.To.Add("Fail@@!.Me"); message.To.Add("this@works"); message.To.Add("*****@*****.**"); using (var client = new SocketLabsClient(ExampleConfig.ServerId, ExampleConfig.ApiKey) { EndpointUrl = ExampleConfig.TargetApi }) { try { var response = client.Send(message); return(response); } catch (Exception e) { Console.WriteLine(e); throw; } } }
public SendResponse RunExample() { var client = new SocketLabsClient(ExampleConfig.ServerId, ExampleConfig.ApiKey); var message = new BasicMessage(); message.To.Add("*****@*****.**"); message.To.Add("*****@*****.**", "Recipient #2"); message.Subject = "Sending Basic Complex Example"; message.HtmlBody = "<body><p><strong>Lorem Ipsum</strong></p><br /><img src=\"cid:Bus\" /></body>"; message.PlainTextBody = "Lorem Ipsum"; message.CharSet = "utf-8"; message.From.Email = "*****@*****.**"; message.ReplyTo.Email = "*****@*****.**"; message.MailingId = "MyMailingId"; message.MessageId = "MyMsgId"; message.CustomHeaders.Add("x-mycustomheader", "I am a message header"); var attachment = message.Attachments.Add("bus.png", MimeType.PNG, @".\examples\img\bus.png"); attachment.ContentId = "Bus"; return(client.Send(message)); }
public SendResponse RunExample() { var message = new BasicMessage(); message.Subject = "Sending A Test Message"; message.HtmlBody = "<html>This is the Html Body of my message.</html>"; message.PlainTextBody = "This is the Plain Text Body of my message."; message.From.Email = "*****@*****.**"; message.ReplyTo.Email = "*****@*****.**"; message.To.Add("*****@*****.**"); message.To.Add("*****@*****.**"); message.Attachments.Add("bus", MimeType.PNG, new byte[] {}); using (var client = new SocketLabsClient(ExampleConfig.ServerId, ExampleConfig.ApiKey) { EndpointUrl = ExampleConfig.TargetApi }) { try { var response = client.Send(message); return(response); } catch (Exception e) { Console.WriteLine(e); throw; } } }
public SendResponse RunExample() { var client = new SocketLabsClient(ExampleConfig.ServerId, ExampleConfig.ApiKey) { EndpointUrl = ExampleConfig.TargetApi }; //Retrieve data from the datasource var customerRepository = new CustomerRepository(); var customers = customerRepository.GetCustomers(); //Build the message var message = new BulkMessage(); message.Subject = "Hello %%FirstName%%"; message.PlainTextBody = "Hello %%FirstName%% %%LastName%%. Is your favorite color still %%FavoriteColor%%?"; message.From.Email = "*****@*****.**"; message.ReplyTo.Email = "*****@*****.**"; //Merge in the customers from the datasource foreach (var customer in customers) { var recipient = new BulkRecipient(customer.EmailAddress); recipient.MergeData.Add("FirstName", customer.FirstName); recipient.MergeData.Add("LastName", customer.LastName); recipient.MergeData.Add("FavoriteColor", customer.FavoriteColor); message.To.Add(recipient); } return(client.Send(message)); }
public SendResponse RunExample() { var client = new SocketLabsClient(ExampleConfig.ServerId, ExampleConfig.ApiKey) { EndpointUrl = ExampleConfig.TargetApi }; var message = new BulkMessage(); // Add some global merge data message.GlobalMergeData.Add("Motto", "When hitting the Inbox matters!"); message.Subject = "Sending A BulkSend with MergeData"; message.HtmlBody = "<html>" + "<head><title>Merge Data Example</title></head>" + "<body>" + " <h1>Global Merge Data</h1>" + " <p>CompanyMotto = %%Motto%%</p>" + " <h1>Per Recipient Merge Data</h1>" + " <p>EyeColor = %%EyeColor%%</p>" + " <p>HairColor = %%HairColor%%</p>" + "</body>" + "</html>"; message.PlainTextBody = "Global Merge Data" + "CompanyMotto = %%Motto%%" + " " + "Per Recipient Merge Data" + " EyeColor = %%EyeColor%%" + " HairColor = %%HairColor%%"; message.From.Email = "*****@*****.**"; message.ReplyTo.Email = "*****@*****.**"; // Add recipients with MergeData var mergeDataFor1 = new Dictionary <string, string>(); mergeDataFor1.Add("EyeColor", "Blue"); mergeDataFor1.Add("HairColor", "Blond"); message.To.Add("*****@*****.**", mergeDataFor1); var recipient2 = message.To.Add("*****@*****.**", "Recipient #1"); recipient2.MergeData.Add("EyeColor", "Green"); recipient2.MergeData.Add("HairColor", "Brown"); var recipient3 = new BulkRecipient("*****@*****.**"); recipient3.AddMergeFields("EyeColor", "Hazel"); recipient3.AddMergeFields("HairColor", "Black"); message.To.Add(recipient3); return(client.Send(message)); }
public SendResponse RunExample() { var client = new SocketLabsClient(ExampleConfig.ServerId, ExampleConfig.ApiKey); // Build the message var message = new BasicMessage(); message.Subject = "Sending Basic Complex Example"; message.HtmlBody = "<body><p><strong>Lorem Ipsum</strong></p><br /><img src=\"cid:Bus\" /></body>"; message.PlainTextBody = "Lorem Ipsum"; message.AmpBody = "<!doctype html>" + "<html amp4email>" + "<head>" + " <meta charset=\"utf-8\">" + " <script async src=\"https://cdn.ampproject.org/v0.js\"></script>" + " <style amp4email-boilerplate>body{visibility:hidden}</style>" + " <style amp-custom>" + " h1 {" + " margin: 1rem;" + " }" + " </style>" + "</head>" + "<body>" + " <h1>This is the AMP Html Body of my message</h1>" + "</body>" + "</html>"; message.CharSet = "utf-8"; // Add recipients message.To.Add("*****@*****.**"); message.To.Add("*****@*****.**", "Recipient #2"); // Set other properties as needed message.From.Email = "*****@*****.**"; message.ReplyTo.Email = "*****@*****.**"; message.MailingId = "MyMailingId"; message.MessageId = "MyMsgId"; message.CustomHeaders.Add("x-mycustomheader", "I am a message header"); var attachment = message.Attachments.Add("bus.png", MimeType.PNG, @".\examples\img\bus.png"); attachment.ContentId = "Bus"; // Send the message return(client.Send(message)); }
/// <summary> /// Sends an Email through SocketLabs API /// </summary> /// <param name="studentObj"></param> private void sendEmailConfirmation(Student studentObj) { int serverId = 38531; String injectionApiKey = "g3QBi56LwSs87Zpq4AXk"; SocketLabsClient emailClient = new SocketLabsClient(serverId, injectionApiKey); BasicMessage message = new BasicMessage(); message.Subject = "Registration Confirmation"; message.HtmlBody = "<p><h3>Welcome to BCIT " + studentObj.FirstName + " you can view your account's details bellow</h3>" + "<br>Student Full Name: " + studentObj.FirstName + " " + studentObj.LastName + "</br>" + "<br>Student Number: " + studentObj.StudentNumber + "</br>" + "<br>Student Email: " + studentObj.Email + "</br>"; message.From.Email = "*****@*****.**"; message.To.Add(studentObj.Email); var res = emailClient.Send(message); Console.WriteLine(res); }
private void sendEmailConfirmationInstructor(Instructor instructorObj) { int serverId = 38531; String injectionApiKey = "g3QBi56LwSs87Zpq4AXk"; SocketLabsClient emailClient = new SocketLabsClient(serverId, injectionApiKey); BasicMessage message = new BasicMessage(); message.Subject = "Registration Confirmation"; message.HtmlBody = "<p><h3>Hello " + instructorObj.FirstName + " This is your password reset details as you have requested.</h3>" + "<br>Please make sure that you reset your password upon logging in</br>" + "<br>Student Password: "******"</br>" + "<br>*** Please ignore this Email if you are not the recipient ***</br>"; message.From.Email = "*****@*****.**"; message.To.Add(instructorObj.Email); var res = emailClient.Send(message); Console.WriteLine(res); }
public SendResponse RunExample() { var client = new SocketLabsClient(ExampleConfig.ServerId, ExampleConfig.ApiKey) { EndpointUrl = ExampleConfig.TargetApi }; // Build the message var message = new BasicMessage(); message.Subject = "Sending A Test Message"; message.HtmlBody = "<html>This Html text will show if Amp is not supported/not implemented properly.</html>"; message.AmpBody = "<!doctype html>" + "<html amp4email>" + "<head>" + " <meta charset=\"utf-8\">" + " <script async src=\"https://cdn.ampproject.org/v0.js\"></script>" + " <style amp4email-boilerplate>body{visibility:hidden}</style>" + " <style amp-custom>" + " h1 {" + " margin: 1rem;" + " }" + " </style>" + "</head>" + "<body>" + " <h1>This is the AMP Html Body of my message</h1>" + "</body>" + "</html>"; // Add recipients message.To.Add("*****@*****.**"); message.To.Add("*****@*****.**", "Recipient #2"); message.To.Add(new EmailAddress("*****@*****.**")); message.To.Add(new EmailAddress("*****@*****.**", "Recipient #4")); // Set other properties as needed message.From.Email = "*****@*****.**"; message.ReplyTo.Email = "*****@*****.**"; //Send message return(client.Send(message)); }
public SendResponse RunExample() { var client = new SocketLabsClient(ExampleConfig.ServerId, ExampleConfig.ApiKey) { EndpointUrl = ExampleConfig.TargetApi }; var message = new BulkMessage(); message.CharSet = "ASCII"; message.Subject = "Sending A BulkSend with MergeData"; message.HtmlBody = "<html>" + "<head><title>ASCII Merge Data Example</title></head>" + "<body>" + " <h1>Merge Data</h1>" + " <p>Complete? = %%Complete%%</p>" + "</body>" + "</html>"; message.PlainTextBody = "Merge Data" + " Complete? = %%Complete%%"; message.From.Email = "*****@*****.**"; message.ReplyTo.Email = "*****@*****.**"; var mergeDataFor1 = new Dictionary <string, string> { { "Complete", "✔" } }; message.To.Add("*****@*****.**", mergeDataFor1); var recipient2 = message.To.Add("*****@*****.**", "Recipient #2"); recipient2.MergeData.Add("Complete", "✔"); var recipient3 = new BulkRecipient("*****@*****.**"); recipient3.MergeData.Add("Complete", "✘"); message.To.Add(recipient3); return(client.Send(message)); }
public SendResponse RunExample() { var client = new SocketLabsClient(ExampleConfig.ServerId, ExampleConfig.ApiKey) { EndpointUrl = ExampleConfig.TargetApi }; var message = new BasicMessage(); message.Subject = "Simple Html file with text"; message.HtmlBody = File.ReadAllText(@".\examples\html\SimpleEmail.html"); message.PlainTextBody = "This is the Plain Text Body of my message."; message.From.Email = "*****@*****.**"; message.ReplyTo.Email = "*****@*****.**"; message.To.Add("*****@*****.**"); return(client.Send(message)); }
public SendResponse RunExample() { var proxy = new WebProxy("http://localhost.:8888", false); var client = new SocketLabsClient(ExampleConfig.ServerId, ExampleConfig.ApiKey, proxy) { EndpointUrl = ExampleConfig.TargetApi }; var message = new BasicMessage(); message.Subject = "Sending A Test Message Through Proxy"; message.HtmlBody = "<html>This is the Html Body of my message.</html>"; message.PlainTextBody = "This is the Plain Text Body of my message."; message.From.Email = "*****@*****.**"; message.ReplyTo.Email = "*****@*****.**"; message.To.Add("*****@*****.**"); return(client.Send(message)); }
public SendResponse RunExample() { var client = new SocketLabsClient(ExampleConfig.ServerId, ExampleConfig.ApiKey) { EndpointUrl = ExampleConfig.TargetApi }; var message = new BasicMessage(); message.Subject = "Sending An ASCII Charset Email"; message.HtmlBody = "<body><p><strong>Lorem Ipsum</strong></p><br />Unicode: ✔ - Check</body>"; message.PlainTextBody = "Lorem Ipsum"; message.CharSet = "ASCII"; message.From.Email = "*****@*****.**"; message.ReplyTo.Email = "*****@*****.**"; message.To.Add("*****@*****.**"); return(client.Send(message)); }
public SendResponse RunExample() { var client = new SocketLabsClient(ExampleConfig.ServerId, ExampleConfig.ApiKey) { EndpointUrl = ExampleConfig.TargetApi }; var message = new BasicMessage(); message.Subject = "Sending An Email With Custom Headers"; message.HtmlBody = "<body><p><strong>Lorem Ipsum</strong></p></body>"; message.PlainTextBody = "Lorem Ipsum"; message.From.Email = "*****@*****.**"; message.ReplyTo.Email = "*****@*****.**"; message.To.Add("*****@*****.**"); message.CustomHeaders.Add("My-Header", "1...2...3..."); message.CustomHeaders.Add("Example-Type", "BasicSendWithCustomHeaders"); return(client.Send(message)); }
public SendResponse RunExample() { var client = new SocketLabsClient(ExampleConfig.ServerId, ExampleConfig.ApiKey) { EndpointUrl = ExampleConfig.TargetApi }; var message = new BasicMessage(); message.Subject = "Sending Using a Template"; message.ApiTemplate = 1; message.MessageId = "DesignerGen"; message.MailingId = "BasicSend"; message.From.Email = "*****@*****.**"; message.ReplyTo.Email = "*****@*****.**"; message.To.Add("*****@*****.**"); return(client.Send(message)); }
public SendResponse RunExample() { var client = new SocketLabsClient(ExampleConfig.ServerId, ExampleConfig.ApiKey) { EndpointUrl = ExampleConfig.TargetApi }; var message = new BulkMessage(); message.Subject = "Sending A Test Message"; message.HtmlBody = "<html>This is the Html Body of my message.</html>"; message.PlainTextBody = "This is the Plain Text Body of my message."; message.From.Email = "*****@*****.**"; message.ReplyTo.Email = "*****@*****.**"; message.To.Add("*****@*****.**"); message.To.Add("*****@*****.**", "Recipient #1"); message.To.Add(new BulkRecipient("*****@*****.**")); message.To.Add(new BulkRecipient("*****@*****.**", "Recipient #4")); return(client.Send(message)); }
public SendResponse RunExample() { var client = new SocketLabsClient(ExampleConfig.ServerId, ExampleConfig.ApiKey) { EndpointUrl = ExampleConfig.TargetApi }; var message = new BasicMessage(); message.Subject = "Sending An Email With An Embedded Image"; message.HtmlBody = "<body><p><strong>Lorem Ipsum</strong></p><br /><img src=\"cid:bus\" /></body>"; message.PlainTextBody = "Lorem Ipsum"; message.From.Email = "*****@*****.**"; message.ReplyTo.Email = "*****@*****.**"; message.To.Add("*****@*****.**"); var attachment = message.Attachments.AddAsync("bus.png", MimeType.PNG, @".\examples\img\bus.png").Result; attachment.ContentId = "bus"; return(client.Send(message)); }
public SendResponse RunExample() { var client = new SocketLabsClient(ExampleConfig.ServerId, ExampleConfig.ApiKey) { EndpointUrl = ExampleConfig.TargetApi }; var message = new BasicMessage(); message.Subject = "Sending An Email With An Attachment"; message.HtmlBody = "<body><p><strong>Lorem Ipsum</strong></p></body>"; message.PlainTextBody = "Lorem Ipsum"; message.From.Email = "*****@*****.**"; message.ReplyTo.Email = "*****@*****.**"; message.To.Add("*****@*****.**"); var attachment = message.Attachments.AddAsync("bus.png", MimeType.PNG, @".\examples\img\bus.png").Result; attachment.CustomHeaders.Add(new CustomHeader("Color", "Orange")); attachment.CustomHeaders.Add(new CustomHeader("Place", "Beach")); return(client.Send(message)); }
public SendResponse RunExample() { var client = new SocketLabsClient(ExampleConfig.ServerId, ExampleConfig.ApiKey) { EndpointUrl = ExampleConfig.TargetApi }; // Build the message var message = new BulkMessage(); // Add some global merge-data (These will be applied to all Recipients unless specifically overridden by Recipient level merge-data) message.GlobalMergeData.Add("Motto", "When hitting the Inbox matters!"); message.GlobalMergeData.Add("Birthday", "Unknown"); message.GlobalMergeData.Add("Age", "an unknown number of"); message.GlobalMergeData.Add("UpSell", "BTW: You are eligible for discount pricing when you upgrade your service!"); // Add recipients with merge data var recipient1 = message.To.Add("*****@*****.**"); recipient1.MergeData.Add("Birthday", "08/05/1991"); recipient1.MergeData.Add("Age", "27"); var recipient2 = message.To.Add("*****@*****.**"); recipient2.MergeData.Add("Birthday", "04/12/1984"); recipient2.MergeData.Add("Age", "34"); recipient2.MergeData.Add("UpSell", ""); // This will override the Global Merge-Data for this specific Recipient var recipient3 = message.To.Add("*****@*****.**"); // The merge-data for this Recipient will be populated with Global Merge-Data recipient3.FriendlyName = "Recipient 3"; // Set other properties as needed message.Subject = "Complex BulkSend Example"; message.From.Set("*****@*****.**", "FromMe"); message.ReplyTo.Email = "*****@*****.**"; message.CustomHeaders.Add(new CustomHeader("testMessageHeader", "I am a message header")); // Build the Content (Note the %% symbols used to denote the data to be merged) var html = new StringBuilder(); html.AppendLine("<html>"); html.AppendLine(" <head><title>Complex</title></head>"); html.AppendLine(" <body>"); html.AppendLine(" <h1>Merged Data</h1>"); html.AppendLine(" <p>"); html.AppendLine(" Motto = <b>%%Motto%%</b> </br>"); html.AppendLine(" Birthday = <b>%%Birthday%%</b> </br>"); html.AppendLine(" Age = <b>%%Age%%</b> </br>"); html.AppendLine(" UpSell = <b>%%UpSell%%</b> </br>"); html.AppendLine(" </p>"); html.AppendLine(" </br>"); html.AppendLine(" <h1>Example of Merge Usage</h1>"); html.AppendLine(" <p>"); html.AppendLine(" Our company motto is '<b>%%Motto%%</b>'. </br>"); html.AppendLine(" Your birthday is <b>%%Birthday%%</b> and you are <b>%%Age%%</b> years old. </br>"); html.AppendLine(" </br>"); html.AppendLine(" <b>%%UpSell%%<b>"); html.AppendLine(" </p>"); html.AppendLine(" </body>"); html.AppendLine("</html>"); message.HtmlBody = html.ToString(); message.PlainTextBody = Regex.Replace(message.HtmlBody, "<.*?>", string.Empty); // Add an Attachment with a custom header var attachment = message.Attachments.AddAsync("bus.png", MimeType.PNG, @".\examples\img\bus.png").Result; attachment.CustomHeaders.Add(new CustomHeader("Attachment-Header", "I Am A Bus")); message.Attachments.Add(attachment); // Send the message return(client.Send(message)); }