Skip to content

Commit f07f9e0

Browse files
committed
updating advance usage file
1 parent 3694ba1 commit f07f9e0

File tree

1 file changed

+84
-87
lines changed

1 file changed

+84
-87
lines changed

advanceUsage.md

Lines changed: 84 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -3,94 +3,91 @@
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.Http;
10-
using Newtonsoft.Json;
11-
using Newtonsoft.Json.Converters;
12-
using Newtonsoft.Json.Linq;
13-
14-
namespace TestConsoleProject
13+
using System.IO;
14+
namespace Testing
1515
{
16-
class MainClass
17-
{
18-
public static void Main(string[] args)
19-
{
20-
//initialization of library
21-
Pepipost.PepipostClient client = new Pepipost.PepipostClient();
22-
EmailController email = client.Email;
23-
EmailBody body = new EmailBody();
24-
25-
string apiKey = "pass api-key here"; //Add your Pepipost APIkey from panel here
26-
27-
body.Personalizations = new List<Personalizations>();
28-
29-
Personalizations body_personalizations_0 = new Personalizations();
30-
31-
// List of Email Recipients
32-
body_personalizations_0.Recipient = "my-email-id@domain.com"; //To/Recipient email address
33-
body_personalizations_0.RecipientCc = new List<string>() {"cc-email-id@domain.com"};
34-
body_personalizations_0.Attributes = new Attributes("{'name':'pepi','love':'mail'}").GetAttributes();
35-
body_personalizations_0.XApiheaderCc = "x api header cc content python";
36-
body_personalizations_0.XApiheader = "xapi header for emails python";
37-
body_personalizations_0.RecipientBcc = new List<string>() { "bcc-email-id@domain.com"};
38-
39-
body_personalizations_0.Attachments = new List<Attachments>();
40-
Attachments body_personalizations_0_attachments_0 = new Attachments();
41-
body_personalizations_0_attachments_0.FileContent = "SGVsbG8sIHRoaXMgZmlsZSBpcyBhbiBpbmZvcm1hdGlvbmFsIGZpbGU6OiBTZW5kaW5nIGVtYWlscyB0byB0aGUgaW5ib3ggaXMgd2hhdCB3ZSBkbywgYnV0IHRoYXTigJlzIG5vdCB0aGUgb25seSByZWFzb24gd2h5IGRldmVsb3BlcnMgYW5kIGVudGVycHJpc2VzIGxvdmUgdXMuIFdlIGFyZSB0aGUgb25seSBFU1AgdGhhdCBkb2VzbuKAmXQgY2hhcmdlIGZvciBlbWFpbHMgb3BlbmVkLg==";
42-
body_personalizations_0_attachments_0.FileName = "pepipost3.txt";
43-
body_personalizations_0.Attachments.Add(body_personalizations_0_attachments_0);
44-
45-
body_personalizations_0.XHeaders = new Xheaders("{'arg1':'value1','arg2':'value2'}").GetXheaders();
46-
body.Personalizations.Add(body_personalizations_0);
47-
body.Tags = "Csharp";
48-
49-
body.From = new From();
50-
51-
// Email Header
52-
body.From.FromEmail = "pepi@net.xyz"; //Sender Email Address. Please note that the sender domain @exampledomain.com should be verified and active under your Pepipost account.
53-
body.From.FromName = "Pepi"; //Sender/From name
54-
55-
//Email Body Content
56-
body.Subject = "Pepipost Test Email Csharp"; //Subject of email
57-
body.Content = "<html><body>Hello, Welcome to Pepipost Family.<br>My name is [% name %].<br>my love is sending [% love %]</body> <br></html>";
58-
body.AmpContent = "<!doctype html><html ⚡4email><head><meta charset=\"utf-8\"><style amp4email-boilerplate>body{visibility:hidden}</style><script async src=\"https://cdn.ampproject.org/v0.js\"></script></head><body>Hello, AMP.</body></html>";
59-
60-
body.Attachments = new List<EmailBodyAttachments>();
61-
EmailBodyAttachments body_attachments_0 = new EmailBodyAttachments();
62-
body_attachments_0.FileContent = "SGVsbG8sIHRoaXMgZmlsZSBpcyBhbiBpbmZvcm1hdGlvbmFsIGZpbGU6OiBTZW5kaW5nIGVtYWlscyB0byB0aGUgaW5ib3ggaXMgd2hhdCB3ZSBkbywgYnV0IHRoYXTigJlzIG5vdCB0aGUgb25seSByZWFzb24gd2h5IGRldmVsb3BlcnMgYW5kIGVudGVycHJpc2VzIGxvdmUgdXMuIFdlIGFyZSB0aGUgb25seSBFU1AgdGhhdCBkb2VzbuKAmXQgY2hhcmdlIGZvciBlbWFpbHMgb3BlbmVkLg==";
63-
body_attachments_0.FileName = "pepipost3.txt";
64-
body.Attachments.Add(body_attachments_0);
65-
66-
body.Settings = new Settings();
67-
body.Settings.Footer = 0;
68-
body.Settings.Clicktrack = 1; //Clicktrack for emails enable=1 | disable=0
69-
body.Settings.Opentrack = 1; //Opentrack for emails enable=1 | disable=0
70-
body.Settings.Unsubscribe = 1; //Unsubscribe for emails enable=1 | disable=0
71-
body.Settings.Bcc = "mybcc-email@email.in";
72-
73-
body.ReplyToId = "replyto@gmail.com";
74-
75-
const string url = "https://<url-endpoint>";
76-
77-
SendEmailResponse result = email.CreateSendEmailAsync(apiKey, body, url).Result;
78-
79-
try
80-
{
81-
if (result.Message.Contains("Error"))
82-
{
83-
Console.WriteLine("\n" + "Message ::" + result.Message + "\n" + "Error Code :: " + result.ErrorInfo.ErrorCode + "\n" + "Error Message ::" + result.ErrorInfo.ErrorMessage + "\n");
84-
}
85-
else
86-
{
87-
Console.WriteLine("\n" + "Message ::" + result.Message);
88-
}
89-
90-
}
91-
catch (APIException) { };
92-
93-
Console.WriteLine("Happy Mailing !");
94-
}
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.ReplyTo = "reply-me-here@mydomain.name";
23+
body.From = new From();
24+
body.From.Email = "hello@your-registered-domain-with-pepipost";
25+
body.From.Name = "Pepipost";
26+
body.Subject = "Pepipost Test Mail from SDK";
27+
body.TemplateId = 123L;
28+
body.Content = new List<Content>();
29+
Content body_content_0 = new Content();
30+
body_content_0.Type = TypeEnum.AMP;
31+
body_content_0.Value = "<!doctype html><html ⚡4email><head><meta charset=\"utf-8\"><style amp4email-boilerplate>body{visibility:hidden}</style><script async src=\"https://cdn.ampproject.org/v0.js\"></script></head><body>Hello, world. This is amp mail 1. </body></html>";
32+
body.Content.Add(body_content_0);
33+
Content body_content_1 = new Content();
34+
body_content_1.Type = TypeEnum.HTML;
35+
body_content_1.Value = "<html><body>Hello, Welcome to Pepipost Family.<br>My name is [% name %].<br>my love is sending [% love %]</body> <br></html>";
36+
body.Content.Add(body_content_1);
37+
body.Attachments = new List<Attachments>();
38+
Attachments body_attachments_0 = new Attachments();
39+
body_attachments_0.Content = "SGVsbG8sIHRoaXMgZmlsZSBpcyBhbiBpbmZvcm1hdGlvbmFsIGZpbGU6OiBTZW5kaW5nIGVtYWlscyB0byB0aGUgaW5ib3ggaXMgd2hhdCB3ZSBkbywgYnV0IHRoYXTigJlzIG5vdCB0aGUgb25seSByZWFzb24gd2h5IGRldmVsb3BlcnMgYW5kIGVudGVycHJpc2VzIGxvdmUgdXMuIFdlIGFyZSB0aGUgb25seSBFU1AgdGhhdCBkb2VzbuKAmXQgY2hhcmdlIGZvciBlbWFpbHMgb3BlbmVkLg==";
40+
body_attachments_0.Name = "global-file.txt";
41+
body.Attachments.Add(body_attachments_0);
42+
body.Personalizations = new List<Personalizations>();
43+
Personalizations body_personalizations_0 = new Personalizations();
44+
body_personalizations_0.Attributes = APIHelper.JsonDeserialize<Object>("{\"name\":\"Pepi\",\"love\":\"Email\"}");
45+
body_personalizations_0.Headers = APIHelper.JsonDeserialize<Object>("{\"Cus-Header1\":\"Cus-Value1\"}");
46+
body_personalizations_0.Attachments = new List<Attachments>();
47+
Attachments body_personalizations_0_attachments_0 = new Attachments();
48+
body_personalizations_0_attachments_0.Content = "SGVsbG8sIHRoaXMgZmlsZSBpcyBhbiBpbmZvcm1hdGlvbmFsIGZpbGU6OiBTZW5kaW5nIGVtYWlscyB0byB0aGUgaW5ib3ggaXMgd2hhdCB3ZSBkbywgYnV0IHRoYXTigJlzIG5vdCB0aGUgb25seSByZWFzb24gd2h5IGRldmVsb3BlcnMgYW5kIGVudGVycHJpc2VzIGxvdmUgdXMuIFdlIGFyZSB0aGUgb25seSBFU1AgdGhhdCBkb2VzbuKAmXQgY2hhcmdlIGZvciBlbWFpbHMgb3BlbmVkLg==";
49+
body_personalizations_0_attachments_0.Name = "personalized-file.txt";
50+
body_personalizations_0.Attachments.Add(body_personalizations_0_attachments_0);
51+
body_personalizations_0.To = new List<EmailStruct>();
52+
EmailStruct body_personalizations_0_to_0 = new EmailStruct();
53+
body_personalizations_0_to_0.Name = "to-name";
54+
body_personalizations_0_to_0.Email = "to-name-address@mydomain.name";
55+
body_personalizations_0.To.Add(body_personalizations_0_to_0);
56+
body_personalizations_0.Cc = new List<EmailStruct>();
57+
EmailStruct body_personalizations_0_cc_0 = new EmailStruct();
58+
body_personalizations_0_cc_0.Name = "to-cc-name";
59+
body_personalizations_0_cc_0.Email = "to-cc-name-address@mydomain.name";
60+
body_personalizations_0.Cc.Add(body_personalizations_0_cc_0);
61+
body_personalizations_0.Bcc = new List<EmailStruct>();
62+
EmailStruct body_personalizations_0_bcc_0 = new EmailStruct();
63+
body_personalizations_0_bcc_0.Name = "to-bcc-name";
64+
body_personalizations_0_bcc_0.Email = "to-bcc-name-address@mydomain.name";
65+
body_personalizations_0.Bcc.Add(body_personalizations_0_bcc_0);
66+
body_personalizations_0.TokenTo = "{\"topic\":\"token-to\"}";
67+
body_personalizations_0.TokenCc = "{\"topic\":\"token-to-cc\"}";
68+
body_personalizations_0.TokenBcc = "{\"topic\":\"token-to-bcc\"}";
69+
body.Personalizations.Add(body_personalizations_0);
70+
body.Settings = new Settings();
71+
body.Settings.Footer = true;
72+
body.Settings.ClickTrack = true;
73+
body.Settings.OpenTrack = true;
74+
body.Settings.UnsubscribeTrack = true;
75+
body.Tags = new List<string>();
76+
body.Tags.Add("campaign-test");
77+
body.LintPayload = true;
78+
body.Schedule = 0L;
79+
body.Bcc = new List<EmailStruct>();
80+
EmailStruct body_bcc_0 = new EmailStruct();
81+
body_bcc_0.Name = "global-bcc";
82+
body_bcc_0.Email = "global-bcc-address@mydomain.name";
83+
body.Bcc.Add(body_bcc_0);
84+
try
85+
{
86+
object result = mailSend.CreateGeneratethemailsendrequestAsync(body).Result;
87+
}
88+
catch (APIException e){};
9589
}
96-
}
90+
}
91+
}
92+
93+
```

0 commit comments

Comments
 (0)