邮件未抄送,通过收件人到我收到 [英] Mail not come CC, through To to i received

查看:163
本文介绍了邮件未抄送,通过收件人到我收到的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有人,

请更正密码.如果是这种形式

Dear All,

please Correct the Code. This if form

<asp:TextBox ID="txtEmail" runat="server" CssClass="textEntry" Text='<%# Bind("EmailId") %>'>


这是web.config.


this is web.config.

<appsettings>
   <add key="UserCode" value="101010" />
   <add key="ReceiverMailId" value="xxxxx@gmail.com" />
   <add key="EmpCC" value="EmailId" />
 </appsettings>


这是CS


this is CS

try
            {
                SmtpSection sec = (SmtpSection)ConfigurationManager.GetSection("system.net/mailSettings/smtp");
                string Host = sec.Network.Host;
                int Port = sec.Network.Port;
                string From = sec.From;
                mailMsg.From = new MailAddress(From);

                mailMsg.To.Add(ConfigurationManager.AppSettings["ReceiverMailId"].ToString());
                mailMsg.CC.Add(ConfigurationManager.AppSettings["EmpCC"].ToString());
                mailMsg.Body = "Please find the attached details of Employee " + empCode;
                mailMsg.Subject = "Tax Saving Proposal details for " + empCode;
                mailMsg.IsBodyHtml = true;

                var fileName = HttpContext.Current.Server.MapPath(@"~/EmpReports/" + empCode + ".PDF");
                string AttachmentName = fileName;
                Attachment att = new Attachment(AttachmentName, "application/pdf");
                att.Name = empCode + "  Details";
                att.ContentDisposition.DispositionType = DispositionTypeNames.Attachment;
                mailMsg.Attachments.Add(att);

                SmtpClient smtp = new SmtpClient(Host, Port);
                NetworkCredential netCred = new NetworkCredential(sec.Network.UserName, sec.Network.Password);
                smtp.Credentials = netCred;
                smtp.Send(mailMsg);
            }


错误消息没收到,我无法发送邮件CC


Errot Message not getting and noc me to mail CC

推荐答案

1. mailMsg.CC.Add(ConfigurationManager.AppSettings["EmpCC"].ToString());
2. <add key="EmpCC" value="EmailId" />
3. Text='<%# Bind("EmailId") %>


基于以下三个方面,很明显,您尝试使用EmailId字段的方式不正确.因此,抄送字段未正确填充以获取电子邮件.

您的``cc''字段正在从网格获取数据,因此您需要从网格中提取数据,而不是强制使用(copy-paste``to''逻辑!)Web.Config.
如果您有一个网格Ui,其中每一行都有一些发送电子邮件的按钮,请使用网格行获取"cc"电子邮件ID并将其用于代码中.否则,可以通过其他任何方式跟踪电子邮件ID,并将其传递给电子邮件方法. Web.config方法肯定不是这种方式.


Based on following three, it''s clear that the way you are trying to use EmailId field is incorrect. Hence, the cc field is not correctly populated to get an email.

Your ''cc'' field is getting data from a grid so you need to pull from there instead of forcefully using(copy-paste ''to'' logic!) Web.Config.
If you have a grid Ui where every row has some button to send an email then use the grid row to get the ''cc'' email id and use it in code. Or else track the email id any other way to pass on to email method. Web.config method is surely not the way.


这篇关于邮件未抄送,通过收件人到我收到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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