在asp.net中使用文本框分割单词

时间:2023-01-28 12:11:05

I m new To ASP.net i want to send mail to multiple people by using one textbox and every email address is separated by ,. Now I want to send mail to multiple people. My code is

我是新的ASP.net我希望通过一个文本框向多个人发送邮件,每个电子邮件地址由,。现在我想发送邮件给多个人。我的代码是

public static void SendEmail(string txtTo, string txtSubject, string txtBody, string txtFrom)
    {
        try
        {
            MailMessage mailMsg = new MailMessage();
            SmtpClient smtp = new SmtpClient("mail.valuesoft.org", 26);
            smtp.Credentials = new NetworkCredential("mail@----.org", "@123");
            mailMsg.From = new MailAddress(txtFrom);
            mailMsg.To.Add(txtTo);
            mailMsg.Subject = txtSubject;
            mailMsg.Body = txtBody;
            mailMsg.IsBodyHtml = true;
            smtp.Send(mailMsg);
        }
        catch { }
    }

1 个解决方案

#1


0  

If you are asking for how to parse a comma seperated list:

如果您要求如何解析逗号分隔列表:

string[] recipients = txtTo.Split(',');
foreach (string recipient in recipients)
{
     mailMsg.To.Add(recipient );
}

#1


0  

If you are asking for how to parse a comma seperated list:

如果您要求如何解析逗号分隔列表:

string[] recipients = txtTo.Split(',');
foreach (string recipient in recipients)
{
     mailMsg.To.Add(recipient );
}