Skip to content

Instantly share code, notes, and snippets.

@nakaji
Created May 2, 2016 08:48
Show Gist options
  • Save nakaji/cd9767632764816d638c351a98a56804 to your computer and use it in GitHub Desktop.
Save nakaji/cd9767632764816d638c351a98a56804 to your computer and use it in GitHub Desktop.
using System;
using System.Net.Mail;
using SendGrid;
namespace SendGripSample
{
class Program
{
static void Main( string[] args)
{
var transportWeb = new SendGrid.Web ("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" );
var message = new SendGridMessage()
{
From = new MailAddress ( "a-nakajima@skynet-sys.co.jp"),
To = new [] { new MailAddress( "a-nakajima@skynet-sys.co.jp" ) },
Subject = "テストメール" ,
Text = "Sendgridからのサンプル.40"
};
message.SetSendAt( new DateTime (2016,5,2,17,40,0).ToUniversalTime());
// Send the email.
try
{
transportWeb.DeliverAsync(message).Wait();
Console .WriteLine("Email sent to " + message.To.GetValue(0));
Console .WriteLine(" \n \nPress any key to continue." );
Console .ReadKey();
}
catch (Exception ex)
{
Console .WriteLine(ex.Message);
Console .WriteLine(" \n \nPress any key to continue." );
Console .ReadKey();
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment