html是纯文本类型么,如何设置内容类型为html和纯文本

通过AWS使用下面的代码发送的邮件是正常的文本格式。邮件格式应该是html格式。在哪里应该包括设置内容类型的选项。使用谷歌搜索,但didn没有找到答案。如何设置内容类型为html和纯文本

using System;

namespace AmazonSESSample

{

class Program

{

static void Main(string[] args)

{

const String FROM = "[email protected]"; // Replace with your "From" address. This address must be verified.

const String TO = "[email protected]"; // Replace with a "To" address. If your account is still in the

// sandbox, this address must be verified.

const String SUBJECT = "Amazon SES test (SMTP interface accessed using C#)";

const String BODY = "This email was sent through the Amazon SES SMTP interface by using C#.";

// Supply your SMTP credentials below. Note that your SMTP credentials are different from your AWS credentials.

const String SMTP_USERNAME = "YOUR_SMTP_USERNAME"; // Replace with your SMTP username.

const String SMTP_PASSWORD = "YOUR_SMTP_PASSWORD"; // Replace with your SMTP password.

// Amazon SES SMTP host name. This example uses the us-west-2 region.

const String HOST = "email-smtp.us-west-2.amazonaws.com";

// Port we will connect to on the Amazon SES SMTP endpoint. We are choosing port 587 because we will use

// STARTTLS to encrypt the connection.

const int PORT = 587;

// Create an SMTP client with the specified host name and port.

using (System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient(HOST, PORT))

{

// Create a network credential with your SMTP user name and password.

client.Credentials = new System.Net.NetworkCredential(SMTP_USERNAME, SMTP_PASSWORD);

// Use SSL when accessing Amazon SES. The SMTP session will begin on an unencrypted connection, and then

// the client will issue a STARTTLS command to upgrade to an encrypted connection using SSL.

client.EnableSsl = true;

// Send the email.

try

{

Console.WriteLine("Attempting to send an email through the Amazon SES SMTP interface...");

client.Send(FROM, TO, SUBJECT, BODY);

Console.WriteLine("Email sent!");

}

catch (Exception ex)

{

Console.WriteLine("The email was not sent.");

Console.WriteLine("Error message: " + ex.Message);

}

}

Console.Write("Press any key to continue...");

Console.ReadKey();

}

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值