在我的一个asp.net页面(C#)中,我使用的是SMTP邮件选项。邮件中的所有内容都可以正常工作,例如主题,收件人地址等,但BCC除外是默认的gmail地址(我用它来验证邮件是如何在其他邮箱中结束的。)
protected void SendEmail(string MemberName, string EmailId)
{
string TextMessage = TBMessage.Text;
string ClubName = TBClubName.Text;
string HtmlTemplate = Server.MapPath("EmailTemplates/PromoteMembers.html");
string content;
string senderID = "promote@example.com";
const string senderPassword = "p@ssw0rd";
using (var strReader = new StreamReader(HtmlTemplate))
{
content = strReader.ReadToEnd();
}
using (StringWriter sw = new StringWriter())
{
using (HtmlTextWriter hw = new HtmlTextWriter(sw))
{
content = content.Replace("<%Name%>", MemberName);
content = content.Replace("<%Message%>", TextMessage);
}
}
string HtmlBody = content;
AlternateView alternateView = AlternateView.CreateAlternateViewFromString(HtmlBody, null, "text/html");
MailMessage m = new MailMessage();
m.AlternateViews.Add(alternateView);
m.From = new MailAddress(senderID, "example.com");
m.To.Add(new MailAddress(EmailId, MemberName));
m.Subject = "Message from " + ClubName;
MailAddress bcc = new MailAddress("example@gmail.com");
m.Bcc.Add(bcc);
SmtpClient smtp = new SmtpClient
{
Host = "mail.example.com",
Port = 8889,
EnableSsl = false,
DeliveryMethod = SmtpDeliveryMethod.Network,
Credentials = new System.Net.NetworkCredential(senderID, senderPassword),
Timeout = 3000000,
};
smtp.Send(m);
}
请让我知道我在这里犯的错误。提前致谢
答案 0 :(得分:0)
我发现了这个问题。
只有Gmail不接受BCC。我想是因为&#34; To&#34;地址有一些包括gmail id,那么它也应该接受BCC。
无论如何,我只想知道邮件是如何在其他邮件收件箱中显示的。所以,我无法通过BCC方法找到它。