blob: 60d108ce6b7630372e8377341e4eba94ffb0d440 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Mail;
using System.Text;
using SendGridMail;
using SendGridMail.Transport;
namespace Example
{
class Program
{
static void Main(String[] args)
{
var restInstance = REST.GetInstance(new NetworkCredential("cjbuchmann", "gadget15"));
//create a new message object
var message = SendGrid.GenerateInstance();
message.AddTo("cj.buchmann@sendgrid.com");
message.From = new MailAddress("cj.buchmann@sendgrid.com");
message.Html = "<div>hello world</div>";
message.Subject = "Hello World SUbject";
message.AddAttachment(@"C:\Users\Public\Pictures\Sample Pictures\Koala.jpg");
message.AddAttachment(@"C:\Users\Public\Pictures\Sample Pictures\Penguins.jpg");
restInstance.Deliver(message);
Console.WriteLine("Message Sent");
Console.WriteLine("DONE!");
}
// this code is used for the SMTPAPI examples
/*static void Main(string[] args)
{
var username = "sgrid_username";
var password = "sgrid_email";
var from = "cj.buchmann@sendgrid.com";
var to = new List<String>
{
"cj.buchmann@sendgrid.com"
};
var bcc = new List<string>
{
"eric@sendgrid.com"
};
var cc = new List<string>
{
"eric@sendgrid.com"
};
//initialize the SMTPAPI example class
var smtpapi = new SMTPAPI(username, password, from, to);
var restpapi = new RESTAPI(username, password, from, to, null, null);
//send a simple HTML encoded email.
//smtpapi.SimpleHTMLEmail();
//send a simple Plaintext email.
//smtpapi.SimplePlaintextEmail();
//send a gravatar enabled email.
//smtpapi.EnableGravatarEmail();
//send an open tracking enabled email.
//smtpapi.EnableOpenTrackingEmail();
restpapi.SimpleHTMLEmail();
}*/
}
}
|