summaryrefslogtreecommitdiffstats
path: root/SendGrid/Example/Program.cs
blob: 7fb096056ff2a8b522963770327738eb465d4806 (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
using System;
using System.Net;
using System.Net.Mail;
using SendGridMail;

namespace Example
{
	internal class Program
	{
		// this code is used for the SMTPAPI examples
		private static void Main()
		{
			// Create the email object first, then add the properties.
			var myMessage = SendGrid.GetInstance();
			myMessage.AddTo("anna@example.com");
			myMessage.From = new MailAddress("john@example.com", "John Smith");
			myMessage.Subject = "Testing the SendGrid Library";
			myMessage.Text = "Hello World!";

			// Create credentials, specifying your user name and password.
			var credentials = new NetworkCredential("username", "password");

			// Create a Web transport for sending email.
			var transportWeb = Web.GetInstance(credentials);

			// Send the email.
			if (transportWeb != null)
				transportWeb.DeliverAsync(myMessage);

			Console.WriteLine("Done!");
			Console.ReadLine();
		}
	}
}