BCC邮件不会 - 代码中的所有其他邮件,如主题和&地址工作正常 [英] BCC mail is not going - all other in the code like subject & to addresses are working fine

查看:73
本文介绍了BCC邮件不会 - 代码中的所有其他邮件,如主题和&地址工作正常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的一个asp.net页面(C#)中,我使用的是SMTP邮件选项。邮件中的一切正常,如主题,地址等,除了BCC到默认的Gmail地址(我用它来验证邮件最终在其他邮箱中)。



In one of my asp.net pages (C#), I am using a SMTP mail option. Everything works fine in the mail such as subject, To addresses etc except for the BCC to a default gmail address (I use this to verify how the mail end up at others mailbox).

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);
        }







请告诉我这里的错误。提前致谢



我尝试过:






Kindly let me know the mistake I am doing here. Thanks in advance

What I have tried:

MailAddress bcc = new MailAddress(&quot;example@gmail.com&quot;);
            m.Bcc.Add(bcc);

推荐答案

你的代码看起来不错,所以我建议这个bug是在MailMessage对象中或在电子邮件服务器中。您可以通过以下方式跟踪哪一个:



1.使用现有的电子邮件客户端(雷鸟或类似客户端)连接到您的电子邮件服务器。发送带有BCC的消息,看看服务器是否实际发送了它。



2.将您的电子邮件保存到文件中。这里有一篇合理的文章(为系统添加保存()功能.Net.Mail.MailMessage [ ^ ])以显示如何执行此操作。确保BCC标题在那里。
Your code looks good, so I would suggest that the bug is either in the MailMessage object, or in your e-mail server. You could track down which one by:

1. Connect to your e-mail server using an existing e-mail client (thunderbird or similar). Send a message with a BCC, and see if the server actually sends it off.

2. Save your e-mail to a file. There is a reasonable article here (Adding Save() functionality to System.Net.Mail.MailMessage[^]) to show how to do that. Make sure the BCC headers are there.


我发现了问题。



只有Gmail不接受BCC。我想,因为To地址有一些包括gmail id和接收邮件,那么它也应该接受BCC。



无论如何,我只想知道邮件是如何获得的显示在其他的Gmail收件箱中。所以,我无法通过BCC方法找到它。
I found the issue.

Only the Gmail is not accepting BCC. I thought since "To" addresses has some including gmail ids & receiving mails, then it should also accept BCC.

Anyway, I only thought of knowing how the mail gets shown up in other's gmail inbox. So, I can't find it through BCC method.


这篇关于BCC邮件不会 - 代码中的所有其他邮件,如主题和&amp;地址工作正常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆