我可以让Web应用程序使用Windows任务计划程序发送自动电子邮件.现在我想使用我为发送电子邮件而编写的以下方法发送HTML格式的电子邮件.
我的代码隐藏:
protected void Page_Load(object sender, EventArgs e)
{
SmtpClient sc = new SmtpClient("mail address");
MailMessage msg = null;
try
{
msg = new MailMessage("xxxx@gmail.com",
"yyyy@gmail.com", "Message from PSSP System",
"This email sent by the PSSP system");
sc.Send(msg);
}
catch (Exception ex)
{
throw ex;
}
finally
{
if (msg != null)
{
msg.Dispose();
}
}
}
Run Code Online (Sandbox Code Playgroud)
怎么做?我只想在电子邮件中添加一些带有一个链接和一个图像的粗体文本.
My Rails 3应用程序以纯文本和HTML格式发送电子邮件.我使用RoundCube和Squirrel Mail客户端在本地测试了它们,它们都显示带有图像,链接等的HTML版本.另一方面,GMail选择纯文本格式.知道是什么导致了这个吗?
Delivered-To: test@gmail.com
Received: by 10.42.166.2 with SMTP id m2cs16081icy;
Thu, 3 Mar 2011 17:01:48 -0800 (PST)
Received: by 10.229.211.138 with SMTP id go10mr1544841qcb.195.1299200507499;
Thu, 03 Mar 2011 17:01:47 -0800 (PST)
Return-Path: <info@example.com>
Received: from beta.example.com (testtest.test.com [69.123.123.123])
by mx.google.com with ESMTP id j14si1690118qcu.136.2011.03.03.17.01.46;
Thu, 03 Mar 2011 17:01:46 -0800 (PST)
Received-SPF: neutral (google.com: 69.123.123.123 is neither permitted nor denied by best guess record for domain of info@example.com) client-ip=69.123.123.123;
Authentication-Results: mx.google.com; spf=neutral (google.com: 69.123.123.123 is neither permitted …Run Code Online (Sandbox Code Playgroud) 尝试构建符合 RFC3156 [0] 的消息,并通过 Gmail API 发送(我使用的是 python 客户端实现)。
我得到的是:在我的 Gmail 邮箱中,邮件已正确发送(我看到的正是我之前构建的邮件)·
我的接收者得到的是:一个“多部分/混合”消息,其有效载荷与我发送的消息相同。
似乎在某些时候,Gmail 更改了我的 Content-Type ......这是真的吗?
作为解决方法,我正在使用 SMTP 连接(它的行为与我预期的一样,正确发送消息),但将来我希望避免这一步,转而使用纯 Gmail API 应用程序。
你能确认这个问题吗?
[0] - 这是一个测试示例:
发送消息:
message_as_str = '''Content-Type: multipart/signed; protocol="application/pgp-signature";\n micalg="pgp-sha512"; boundary="===============0594182808971957567=="\nMIME-Version: 1.0\nDate: Wed, 12 Nov 2014 12:18:02 +0100\nSubject: A test email\nFrom: Leo Iannacone <l3on@ubuntu.com>\nTo: Andrea Colangelo <warp10@ubuntu.com>\n\n--===============0594182808971957567==\nContent-Type: text/plain; charset="utf-8"\r\nMIME-Version: 1.0\r\nContent-Transfer-Encoding: quoted-printable\r\n\r\nHello,\r\n\r\nthis is a signed email (RFC 3156).\r\n\r\nBest,\r\nL.\r\n\r\n-- =\r\n\r\nUbuntu Member - http://launchpad.net/~l3on\r\nHome Page - http://leoiannacone.com\r\nGPG Key Id - 0xD282FC25\r\n\n--===============0594182808971957567==\nContent-Type: application/pgp-signature; name="signature.asc"\nContent-Description: GooPG digital signature\n\n-----BEGIN PGP SIGNATURE-----\nVersion: GnuPG …Run Code Online (Sandbox Code Playgroud)