Skip to content

Commit 5cf576d

Browse files
Formatting
1 parent a62cac8 commit 5cf576d

File tree

1 file changed

+92
-92
lines changed

1 file changed

+92
-92
lines changed

USE_CASES.md

Lines changed: 92 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -18,28 +18,28 @@ using System.IO;
1818

1919
namespace Example
2020
{
21-
internal class Example
22-
{
23-
private static void Main()
24-
{
25-
Execute().Wait();
26-
}
27-
28-
static async Task Execute()
29-
{
30-
var apiKey = Environment.GetEnvironmentVariable("SENDGRID_API_KEY");
31-
var client = new SendGridClient(apiKey);
32-
var from = new EmailAddress("[email protected]");
33-
var subject = "Subject";
34-
var to = new EmailAddress("[email protected]");
35-
var body = "Email Body";
36-
var msg = MailHelper.CreateSingleEmail(from, to, subject, body, "");
37-
var bytes = File.ReadAllBytes("/Users/username/file.txt");
38-
var file = Convert.ToBase64String(bytes);
39-
msg.AddAttachment("file.txt", file);
40-
var response = await client.SendEmailAsync(msg);
41-
}
42-
}
21+
internal class Example
22+
{
23+
private static void Main()
24+
{
25+
Execute().Wait();
26+
}
27+
28+
static async Task Execute()
29+
{
30+
var apiKey = Environment.GetEnvironmentVariable("SENDGRID_API_KEY");
31+
var client = new SendGridClient(apiKey);
32+
var from = new EmailAddress("[email protected]");
33+
var subject = "Subject";
34+
var to = new EmailAddress("[email protected]");
35+
var body = "Email Body";
36+
var msg = MailHelper.CreateSingleEmail(from, to, subject, body, "");
37+
var bytes = File.ReadAllBytes("/Users/username/file.txt");
38+
var file = Convert.ToBase64String(bytes);
39+
msg.AddAttachment("file.txt", file);
40+
var response = await client.SendEmailAsync(msg);
41+
}
42+
}
4343
}
4444
```
4545

@@ -55,12 +55,12 @@ using System.Collections.Generic;
5555

5656
namespace KitchenSink
5757
{
58-
internal class KitchenSink
59-
{
60-
private static void Main()
61-
{
62-
Execute().Wait();
63-
}
58+
internal class KitchenSink
59+
{
60+
private static void Main()
61+
{
62+
Execute().Wait();
63+
}
6464

6565
static async Task Execute()
6666
{
@@ -70,7 +70,7 @@ namespace KitchenSink
7070

7171
// For a detailed description of each of these settings, please see the [documentation](https://sendgrid.com/docs/API_Reference/api_v3.html).
7272
73-
msg.AddTo(new EmailAddress("[email protected]", "Example User 1"));
73+
msg.AddTo(new EmailAddress("[email protected]", "Example User 1"));
7474
var to_emails = new List<EmailAddress>
7575
{
7676
new EmailAddress("[email protected]", "Example User2"),
@@ -193,106 +193,106 @@ namespace KitchenSink
193193
new Content("text/calendar", "Party Time!!"),
194194
new Content("text/calendar2", "Party Time2!!")
195195
};
196-
msg.AddContents(contents);
196+
msg.AddContents(contents);
197197

198-
// For base64 encoding, see [`Convert.ToBase64String`](https://msdn.microsoft.com/en-us/library/system.convert.tobase64string(v=vs.110).aspx)
198+
// For base64 encoding, see [`Convert.ToBase64String`](https://msdn.microsoft.com/en-us/library/system.convert.tobase64string(v=vs.110).aspx)
199199
// For an example using an attachment, please see this [use case](https://github.com/sendgrid/sendgrid-csharp/blob/master/USE_CASES.md#attachments).
200-
msg.AddAttachment("balance_001.pdf",
201-
"base64 encoded string",
202-
"application/pdf",
203-
"attachment",
204-
"Balance Sheet");
200+
msg.AddAttachment("balance_001.pdf",
201+
"base64 encoded string",
202+
"application/pdf",
203+
"attachment",
204+
"Balance Sheet");
205205
var attachments = new List<Attachment>()
206206
{
207-
new Attachment()
207+
new Attachment()
208+
{
209+
Content = "base64 encoded string",
210+
Type = "image/png",
211+
Filename = "banner.png",
212+
Disposition = "inline",
213+
ContentId = "Banner"
214+
},
215+
new Attachment()
208216
{
209-
Content = "base64 encoded string",
210-
Type = "image/png",
211-
Filename = "banner.png",
212-
Disposition = "inline",
213-
ContentId = "Banner"
214-
},
215-
new Attachment()
216-
{
217-
Content = "base64 encoded string",
218-
Type = "image/png",
219-
Filename = "banner2.png",
220-
Disposition = "inline",
221-
ContentId = "Banner 2"
222-
}
217+
Content = "base64 encoded string",
218+
Type = "image/png",
219+
Filename = "banner2.png",
220+
Disposition = "inline",
221+
ContentId = "Banner 2"
222+
}
223223
};
224-
msg.AddAttachments(attachments);
224+
msg.AddAttachments(attachments);
225225

226226
// For a full transactional template example, please see this [use case](https://github.com/sendgrid/sendgrid-csharp/blob/master/USE_CASES.md#transactional-templates).
227-
msg.SetTemplateId("13b8f94f-bcae-4ec6-b752-70d6cb59f932");
227+
msg.SetTemplateId("13b8f94f-bcae-4ec6-b752-70d6cb59f932");
228228

229229
msg.AddGlobalHeader("X-Day", "Monday");
230-
var globalHeaders = new Dictionary<string, string>
230+
var globalHeaders = new Dictionary<string, string>
231231
{
232232
{ "X-Month", "January" },
233233
{ "X-Year", "2017" }
234234
};
235235
msg.AddGlobalHeaders(globalHeaders);
236236

237-
msg.AddSection("%section1", "Substitution for Section 1 Tag");
238-
var sections = new Dictionary<string, string>
239-
{
240-
{"%section2%", "Substitution for Section 2 Tag"},
241-
{"%section3%", "Substitution for Section 3 Tag"}
242-
};
243-
msg.AddSections(sections);
237+
msg.AddSection("%section1", "Substitution for Section 1 Tag");
238+
var sections = new Dictionary<string, string>
239+
{
240+
{"%section2%", "Substitution for Section 2 Tag"},
241+
{"%section3%", "Substitution for Section 3 Tag"}
242+
};
243+
msg.AddSections(sections);
244244

245-
msg.AddCategory("customer");
246-
var categories = new List<string>
245+
msg.AddCategory("customer");
246+
var categories = new List<string>
247247
{
248248
"vip",
249249
"new_account"
250250
};
251-
msg.AddCategories(categories);
251+
msg.AddCategories(categories);
252252

253-
msg.AddGlobalCustomArg("campaign", "welcome");
254-
var globalCustomArgs = new Dictionary<string, string>
253+
msg.AddGlobalCustomArg("campaign", "welcome");
254+
var globalCustomArgs = new Dictionary<string, string>
255255
{
256256
{ "sequence2", "2" },
257257
{ "sequence3", "3" }
258258
};
259-
msg.AddGlobalCustomArgs(globalCustomArgs);
259+
msg.AddGlobalCustomArgs(globalCustomArgs);
260260

261261
msg.SetAsm(3, new List<int>() { 1, 4, 5 });
262262

263-
msg.SetGlobalSendAt(1461775051);
263+
msg.SetGlobalSendAt(1461775051);
264264

265-
msg.SetIpPoolName("23");
266-
265+
msg.SetIpPoolName("23");
266+
267267
// This must be a valid [batch ID](https://sendgrid.com/docs/API_Reference/SMTP_API/scheduling_parameters.html)
268-
//msg.SetBatchId("some_batch_id");
268+
//msg.SetBatchId("some_batch_id");
269269
270-
msg.SetBccSetting(true, "[email protected]");
270+
msg.SetBccSetting(true, "[email protected]");
271271

272-
msg.SetBypassListManagement(true);
273-
272+
msg.SetBypassListManagement(true);
273+
274274
msg.SetFooterSetting(true, "Some Footer HTML", "Some Footer Text");
275-
275+
276276
msg.SetSandBoxMode(true);
277-
277+
278278
msg.SetSpamCheck(true, 1, "https://gotchya.example.com");
279-
279+
280280
msg.SetClickTracking(true, false);
281-
281+
282282
msg.SetOpenTracking(true, "Optional tag to replace with the open image in the body of the message");
283-
283+
284284
msg.SetSubscriptionTracking(true,
285-
"HTML to insert into the text / html portion of the message",
286-
"text to insert into the text/plain portion of the message",
287-
"substitution tag");
288-
285+
"HTML to insert into the text / html portion of the message",
286+
"text to insert into the text/plain portion of the message",
287+
"substitution tag");
288+
289289
msg.SetGoogleAnalytics(true,
290-
"some campaign",
291-
"some content",
292-
"some medium",
293-
"some source",
294-
"some term");
295-
290+
"some campaign",
291+
"some content",
292+
"some medium",
293+
"some source",
294+
"some term");
295+
296296
msg.SetReplyTo(new EmailAddress("[email protected]", "Reply To Me"));
297297

298298
var response = await client.SendEmailAsync(msg);
@@ -301,8 +301,8 @@ namespace KitchenSink
301301
Console.WriteLine(response.Body.ReadAsStringAsync().Result);
302302
Console.WriteLine(response.Headers);
303303
Console.ReadLine();
304-
}
305-
}
304+
}
305+
}
306306
}
307307
```
308308

@@ -328,7 +328,7 @@ Template Body:
328328
```html
329329
<html>
330330
<head>
331-
<title></title>
331+
<title></title>
332332
</head>
333333
<body>
334334
Hello -name-,

0 commit comments

Comments
 (0)