2012-03-18 26 views
-5

Amazon SESを使用して電子メールを送信しています。 Amazon SESを使用してC#で添付ファイル付きのメールを送信するには?Amazon SESを使用してC#で添付ファイル付きの電子メールを送信

コード:AmazonでSESについての特別な

  AmazonSimpleEmailServiceConfig amConfig = new AmazonSimpleEmailServiceConfig(); 
      amConfig.UseSecureStringForAwsSecretKey = false; 
      AmazonSimpleEmailServiceClient amzClient = new AmazonSimpleEmailServiceClient("username", "password", amConfig); 
      ArrayList to = new ArrayList();       
      to.Add("[email protected]"); 

      Destination dest = new Destination(); 
      dest.WithBccAddresses((string[])to.ToArray(typeof(string))); 
      string body = "INSERT HTML BODY HERE"; 
      string subject = "INSERT EMAIL SUBJECT HERE"; 
      Body bdy = new Body(); 
      bdy.Html = new Amazon.SimpleEmail.Model.Content(body); 
      Amazon.SimpleEmail.Model.Content title = new Amazon.SimpleEmail.Model.Content(subject); 
      Message message = new Message(title, bdy); 
      SendEmailRequest ser = new SendEmailRequest("[email protected]", dest, message); 
      SendEmailResponse seResponse = amzClient.SendEmail(ser); 
      SendEmailResult seResult = seResponse.SendEmailResult; 
+1

あなたはCESで他の電子メールを送信するのと同じ方法でSESで電子メールを送信します。 C#コード、特定の質問、およびコードから受け取った特定のエラーを投稿する必要があります。 – paulsm4

+0

ありがとうございます。私は添付ファイル付きのメールを送信するコードを – sharmila

答えて

1

何もない、ちょうどあなたのSMTPサーバーを指定し、それを送信してください。

public static void SendWithSMTP(string name, string pass, string host, int port) 
{ 
    using (var client = new System.Net.Mail.SmtpClient(host, port)) 
    { 
     client.Credentials = new System.Net.NetworkCredential(name, pass); 
     client.EnableSsl = true; 
     MailMessage mail = new MailMessage("[email protected]","[email protected]",head, body); 
     mail.Attachments.Add(new Attachment("specify your attachment path")); 
     client.Send(mail); 
    } 
} 
+0

ありがとう。私は添付ファイルなしで電子メールを送信するようにコーディングしました。私は添付ファイル – sharmila

+2

で電子メールが必要ですが、私の例では添付ファイルがあります。 –

+0

申し訳ありません。私は気づかなかった。私が試してみましょう。ありがとう – sharmila

-2

ファイルurlを送信し、ユーザーにファイルのダウンロードを要求することができます。

関連する問題