CC和TO字段中的邮件发送问题 [英] mail sending problem in CC and TO fields

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

问题描述

我使用此代码发送邮件设置我的公司域名,它工作得很好但问题是,当我在TO,CC字段中提到多个收件人然后它发送确定但是当我检查收件箱并检查TO,FROM然后第一个收件人出现多次,其他收件人不会出现在CC,To field。



eg我发邮件到:user@yahoo.com; fatman@gmail.com; CC:groomed@ymail.com与CC:hh@ymail.com; jesse@ugnada.com.uk



然后它向所有TO和CC收件人发送邮件,但在收件箱中当我查看电子邮件然后在CC上方时,TO显示如下:



TO:user@yahoo.com ;; user@yahoo.com; user@yahoo.com



CC:hh@ymail.com ;; hh@ymail.com ;; hh@ymail.com;



为什么?



代码:



i am usign this code to send mails on setting of my company domain, it's working perfectly but problem is that when i mention multiple recipients in TO, CC field then it sends OK but when i check inbox and check TO, FROM then first recipient appears many times and other recipients don't appear in CC, To field.

e.g. i send mails TO: user@yahoo.com; fatman@gmail.com; groomed@ymail.com with CC: hh@ymail.com; jesse@ugnada.com.uk

then it deliver mails to all TO and CC recipients but in inbox when i check email then above CC, TO appears like this:

TO: user@yahoo.com;; user@yahoo.com; user@yahoo.com

CC: hh@ymail.com;; hh@ymail.com;; hh@ymail.com;

why ?

code:

SmtpClient SmtpServer = new SmtpClient("mail.precisetech.com.pk");
                var mail = new MailMessage();
                mail.From = new MailAddress("hunain@precisetech.com.pk");

                string[] to = txtEmailTo.Split(';');
                foreach (string mailTo in to)
                {
                    mail.To.Add(txtEmailTo);
                }

                string[] cc = txtCC.Split(';');
                foreach (string copyTo in cc) 
                {
                    MailAddress cCopy = new MailAddress(txtCC);
                    mail.CC.Add(cCopy);
                } 
                mail.Subject = txtSubject;
                mail.IsBodyHtml = true;
               // mail.CC = txtCC;
                string htmlBody;
                htmlBody = txtBody;
                mail.Body = txtBody;
                SmtpServer.Port = 25;
                SmtpServer.UseDefaultCredentials = false;
                SmtpServer.Credentials = new System.Net.NetworkCredential("hunain@precisetech.com.pk","");
                SmtpServer.EnableSsl = false;
               
			
	
	     try {
                SmtpServer.Send(mail);
                ViewBag.Confirmation = "Daily Log Has Been Submitted";
                return View();
             }
         
         catch (Exception ex) 
             {
               ViewBag.Confirmation = ex.Message;
               return View();
  	         }

推荐答案

每次都不需要添加cc或bcc地址。您可以通过以逗号(,)分隔传递字符串一次添加所有地址。
No need to add the cc or bcc address each time. you can add the all addresses at a time by passing the string with seperated by comma(,).


这篇关于CC和TO字段中的邮件发送问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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