码迷,mamicode.com
首页 > 其他好文 > 详细

使用azure send grid发送email

时间:2017-07-21 10:34:23      阅读:219      评论:0      收藏:0      [点我收藏+]

标签:console   world   pkg   string   fill   direct   data-   csharp   portal   

1. create a send grid account

技术分享

技术分享

2. remember the username/password of the send grid account


技术分享


3. install sendgrid nuget pkg

技术分享
4. get key


manage ->it will redirect you to manage portal
技术分享


create a new api key:
技术分享
4. sample code of console application


using System;
using System.Net.Mail;
using SendGrid;


namespace SendGridAzureSample
{
    class Program
    {
        static void Main(string[] args)
        {
            SendGridMessage myMessage = new SendGridMessage();
            myMessage.AddTo("send_to");
            myMessage.From = new MailAddress("from_email", "Display name");
            myMessage.Subject = "Testing the SendGrid Library";
            myMessage.Text = "Hello World!";


            //myMessage.AddAttachment(@"attachment_path");




            var key = "your_key";
            // create a Web transport, using API Key
            var transportWeb = new Web(key);
            transportWeb.DeliverAsync(myMessage);


            Console.ReadKey();
        }
    }
}



reference link : https://azure.microsoft.com/en-us/documentation/articles/sendgrid-dotnet-how-to-send-email/

使用azure send grid发送email

标签:console   world   pkg   string   fill   direct   data-   csharp   portal   

原文地址:http://www.cnblogs.com/gccbuaa/p/7215928.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!