Skip to content

Commit 3694ba1

Browse files
committed
updating simple -usage file
1 parent 06818db commit 3694ba1

File tree

1 file changed

+52
-58
lines changed

1 file changed

+52
-58
lines changed

simpleUsage.md

Lines changed: 52 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -3,67 +3,61 @@
33
```csharp
44
using System;
55
using System.Collections.Generic;
6-
using Pepipost.Controllers;
6+
using System.Globalization;
7+
using System.Threading.Tasks;
8+
using Pepipost;
9+
using Pepipost.Utilities;
710
using Pepipost.Models;
11+
using Pepipost.Controllers;
812
using Pepipost.Exceptions;
9-
using Pepipost.Utilities;
10-
using Pepipost.Http;
11-
using Newtonsoft.Json;
12-
using Newtonsoft.Json.Converters;
13-
using Newtonsoft.Json.Linq;
14-
15-
namespace TestConsoleProject
13+
using System.IO;
14+
namespace Testing
1615
{
17-
class MainClass
18-
{
19-
public static void Main(string[] args)
20-
{
21-
//initialization of library
22-
Pepipost.PepipostClient client = new Pepipost.PepipostClient();
23-
EmailController email = client.Email;
24-
EmailBody body = new EmailBody();
25-
26-
string apiKey = "Your api key here"; //Add your Pepipost APIkey from panel here
27-
28-
body.Personalizations = new List<Personalizations>();
29-
30-
Personalizations body_personalizations_0 = new Personalizations();
31-
32-
// List of Email Recipients
33-
body_personalizations_0.Recipient = "recipient@exampledomain.com"; //To/Recipient email address
34-
body_personalizations_0.Attributes = APIHelper.JsonDeserialize<Object>("{}");
35-
body.Personalizations.Add(body_personalizations_0);
36-
37-
body.From = new From();
38-
39-
// Email Header
40-
body.From.FromEmail = "sender@exampledomain.com"; //Sender Email Address. Please note that the sender domain @exampledomain.com should be verified and active under your Pepipost account.
41-
body.From.FromName = "Pepi"; //Sender/From name
42-
43-
//Email Body Content
44-
body.Subject = "Pepipost Test Email"; //Subject of email
45-
body.Content = "<html><body>Hey,<br><br>Congratulations, Integration is Successfully Completed.<br>This is your first email from Pepipost C# library.<br>Happy Emailing<br><br>Thanks,<br>Pepipost";
46-
body.Settings = new Settings();
47-
48-
body.Settings.Footer = 0;
49-
body.Settings.Clicktrack = 1; //Clicktrack for emails enable=1 | disable=0
50-
body.Settings.Opentrack = 1; //Opentrack for emails enable=1 | disable=0
51-
body.Settings.Unsubscribe = 1; //Unsubscribe for emails enable=1 | disable=0
52-
SendEmailResponse result = email.CreateSendEmailAsync(apiKey, body).Result;
53-
54-
try
55-
{
56-
if(result.Message.Contains("Error")){
57-
Console.WriteLine("\n" + "Message ::" + result.Message + "\n" + "Error Code :: " + result.ErrorInfo.ErrorCode + "\n" + "Error Message ::" + result.ErrorInfo.ErrorMessage + "\n");
58-
}else{
59-
Console.WriteLine("\n" + "Message ::" + result.Message);
60-
}
61-
62-
}
63-
catch (APIException) { };
64-
65-
Console.WriteLine("Happy Mailing !");
66-
}
16+
class Program {
17+
static void Main(string[] args){
18+
Configuration.ApiKey = "api_key";
19+
PepipostClient client = new PepipostClient();
20+
MailSendController mailSend = client.MailSend;
21+
Send body = new Send();
22+
body.From = new From();
23+
body.From.Email = "hello@your-registered-domain-with-pepipost";
24+
body.From.Name = "Pepipost";
25+
body.Subject = "Pepipost Test Mail from SDK";
26+
body.Content = new List<Content>();
27+
Content body_content_0 = new Content();
28+
body_content_0.Type = Type.HTML;
29+
body_content_0.Value = "<html><body>Hello, Welcome to Pepipost Family.<br>My name is [% name %].<br>my love is sending [% love %]</body> <br></html>";
30+
body.Content.Add(body_content_0);
31+
body.Personalizations = new List<Personalizations>();
32+
Personalizations body_personalizations_0 = new Personalizations();
33+
body_personalizations_0.Attributes = APIHelper.JsonDeserialize<Object>("{\"name\":\"Pepi\",\"love\":\"Email\"}");
34+
body_personalizations_0.To = new List<EmailStruct>();
35+
EmailStruct body_personalizations_0_to_0 = new EmailStruct();
36+
body_personalizations_0_to_0.Name = "to-address";
37+
body_personalizations_0_to_0.Email = "to-address@mydomain.name";
38+
body_personalizations_0.To.Add(body_personalizations_0_to_0);
39+
body_personalizations_0.Cc = new List<EmailStruct>();
40+
EmailStruct body_personalizations_0_cc_0 = new EmailStruct();
41+
body_personalizations_0_cc_0.Name = "to-cc-name";
42+
body_personalizations_0_cc_0.Email = "to-bcc-name";
43+
body_personalizations_0.Cc.Add(body_personalizations_0_cc_0);
44+
body_personalizations_0.Bcc = new List<EmailStruct>();
45+
EmailStruct body_personalizations_0_bcc_0 = new EmailStruct();
46+
body_personalizations_0_bcc_0.Name = "to-bcc-name";
47+
body_personalizations_0_bcc_0.Email = "to-bcc-name@mydomain.name";
48+
body_personalizations_0.Bcc.Add(body_personalizations_0_bcc_0);
49+
body.Personalizations.Add(body_personalizations_0);
50+
body.Settings = new Settings();
51+
body.Settings.Footer = true;
52+
body.Settings.ClickTrack = true;
53+
body.Settings.OpenTrack = true;
54+
body.Settings.UnsubscribeTrack = true;
55+
try
56+
{
57+
object result = mailSend.CreateGeneratethemailsendrequestAsync(body).Result;
58+
}
59+
catch (APIException e){};
6760
}
61+
}
6862
}
6963
```

0 commit comments

Comments
 (0)