to和CC字段中的电子邮件地址相同 [英] Same email address in both to and CC fields

查看:252
本文介绍了to和CC字段中的电子邮件地址相同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,





我在TO和CC字段中添加了一个电子邮件地址(两个文本框中都有相同的电子邮件) 。收件人收到两封电子邮件。



我的测试人员只期待一封邮件,我尝试从CC字段中删除重复的电子邮件。但我的测试人员期待当他打开ibox并看到TO和CC字段时,他应该在TO和CC字段中看到电子邮件地址。





Hi All,


I've added an email address in both TO and CC fields(same email in both textboxes). The recipient is getting two emails.

My tester is expecting only one mail, I tried removing the duplicate email from CC field. But my tester is expecting when he opens the ibox and see the TO and CC fields then he should see the email address in both TO and CC fields.


public ActionResult SaveSendNotification(SendNotificationCommonForAll dto)
        {
            try
            {
                string[] CCList = { string.Empty };
                string[] ToList = { string.Empty };
                Guid guid = new Guid();

                UserDTO userDTO = (UserDTO)Session["UserDto"];
                string senderEmailId = userDTO.Email;
if (!string.IsNullOrEmpty(dto.SendNotificationCommon.ToRecipients))
                {
                    ToList = dto.SendNotificationCommon.ToRecipients.Split(new[] { ';', ',' });
                    if (ToList.Contains(System.Configuration.ConfigurationManager.AppSettings["DLKey"]))
                    {
                        string allEmails = string.Empty;
                        foreach (string s in UserAccountService.GetUsersForMailSend(userDTO.CreatedBy).ToList())
                        {
                            if (s != "" || s != string.Empty)
                                allEmails = allEmails + s + ",";
                        }
                        ToList = allEmails.Split(new[] { ';', ',' });
                        ToList = ToList.Where(x => !string.IsNullOrEmpty(x)).ToArray();
                        
                    }
                    foreach (string mail in ToList)
                    {
                        if (!IsValid(mail))
                        {
                            TempData["ResultMessage"] = "Invalid To mail: " + mail;
                            return RedirectToAction("Index", new { guid = guid, NotificationType = dto.SendNotificationCommon.NotificationType });
                        }
                    }
                    ToList = new HashSet<string>(ToList).ToArray();
                }

                if (!string.IsNullOrEmpty(dto.SendNotificationCommon.CcRecipients))
                {
                    CCList = dto.SendNotificationCommon.CcRecipients.Split(new[] { ';', ',' });
                    foreach (string mail in CCList)
                    {
                        if (!IsValid(mail))
                        {
                            TempData["ResultMessage"] = "Invalid Cc mail: " + mail;
                            return RedirectToAction("Index", new { guid = guid, NotificationType = dto.SendNotificationCommon.NotificationType });
                        }
                    }
                    CCList = new HashSet<string>(CCList).ToArray();
                }
                CCList = CCList.Where(s => !string.IsNullOrEmpty(s)).ToArray();
                CCList= CCList.Except(ToList).ToArray();
                Email emaildetails = new Email(ToList, dto.HTMLEditor.HtmlContent, CCList, null, dto.SendNotificationCommon.Subject, Configurations.MailUser, new EmailConfiguration { HostName = Configurations.MailUser, ServerName = Configurations.MailServer, Password = Configurations.MailUserPassword, Port = Convert.ToInt16(Configurations.MailPortNumber) });
                SmtpClient smtpClient = new SmtpClient();
                MailMessage mailObject = new MailMessage();


                AdminSettingsDto AdminDTO = AdminSettingsCache.GetAdminsettingsFromCache();
                if (emaildetails.SendTo != null)
                {
                    mailObject = PrepareMailMessage(emaildetails);
                    string smtpServerName = AdminDTO.SmtpServerName.Trim();
                    string userName = AdminDTO.Email;
                    string password = AdminDTO.Password;
                    NetworkCredential networkCredential = new NetworkCredential(userName, password);
                    smtpClient.Host = smtpServerName;
                    smtpClient.UseDefaultCredentials = false;
                    smtpClient.Credentials = networkCredential;
                    smtpClient.EnableSsl = Configurations.EnableSSL;
                    smtpClient.Port = (int)AdminDTO.Port;


                    //todo: needs to be uncommented on production
                    smtpClient.Send(mailObject);
}





谢谢..



问候,

Ravikumar G.



我的尝试:



我已经搜索了这个,但没有得到任何线索。



Thank you..

Regards,
Ravikumar G.

What I have tried:

I've googled for this but didn't get any clues.

推荐答案

你的测试人员不知道他在说什么。如果多次指定相同的地址,则会多次发送。它并不关心指定地址的目标字段(To,Cc,Bcc)。 SMTP服务器将解析所有字段并将邮件转发给每个列出的收件人。



邮件客户端将只显示收件人和抄送目标字段的内容。 收件人字段中列出的地址不会显示在客户端的抄送字段中。



您的测试人员应该了解这些字段的用途:



To适用于可能接听的实际收件人。



Cc是为其他收件人提供通知但不希望回答。



密送类似于抄送,但该字段已从邮件中删除(或修改)传输时。



另见 3.6.3节。 RFC 2822 的目标地址字段 [ ^ ]。
Your tester does not know what he talks about. If you specify the same address multiple times, it will be send multiple times. It does not care in which of the destination fields ("To", "Cc", "Bcc") the address is specified. The SMTP server will parse all fields and forward the message to each listed recipient.

Mail clients will just show the content of the "To" and "Cc" destination fields. An address listed in the "To" field only will not be shown in the "Cc" field of the client.

Your tester should understand the purpose of those fields:

"To" is for the actual recipient(s) which might answer.

"Cc" is for additional recipients to get them informed but not expected to answer.

"Bcc" is like "Cc" but the field is removed from the mail (or modified) upon transmission.

See also section 3.6.3. Destination address fields of RFC 2822[^].


这篇关于to和CC字段中的电子邮件地址相同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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