2017-11-16 41 views
0

に送信しました。送信時にAmazonのSESプロバイダにメールを送信したいという単純なフォームを作成しました。 これを実現するにはどうしたらよいですか?.NET Core 2.0にメールを送信できるライブラリがありますか?asp.netコア2.0のメールをAmazon SES

BTW:私はフロントエンドで角度を使用しています。バックエンドではWebAPIを使用しています。

答えて

0

AWSSDKが.net Core 2.0を完全にサポートしているので、これは簡単に実現できます。

インストールAWSSDK.SimpleEmailその後

public async Task<bool> SendEmail(string from, string to, string subject, string html){ 
    // might want to provide credentials 
    using(var ses = new AmazonSimpleEmailServiceClient(RegionEndpoint.USEast1)) 

     { 
    var sendResult = await ses.SendEmailAsync(new SendEmailRequest 
      { 
        Source = from, 
        Destination = new Destination(to) { CcAddresses = "if you need them", BccAddresses = "or these" }, 
        Message = new Message 
        { 
         Subject = new Content(subject), 
         Body = new Body 
         { 
          Html = new Content(html) 
         } 
        } 
       }); 
     return sendResult.HttpStatusCode == HttpStatusCode.OK; 
     } 
}