更新时间:2023-01-09 20:55:09
To MailMessage可以包含MailAddresses集合或逗号分隔的地址。使用以下代码
MailMessage message = new MailMessage(); ms.From = New MailAddress(from); //可以包含MailAddressCollection或逗号分隔的地址 ms.To.Add( " first@domain.com,second @ domain.com" ); I designed a form that needs to be sent to multiple addresses, here is the code that i have to send it to just one. It isn't live yet so I'm simply looping it to myself for testing purposes. How would I code it for multiple addresses coming from different end users.
protected
void SendEmail(string toEmail, string ccEmail, int employeeDataId){
string from = "jgarofalo@pvsc.com";
toEmail = "jgarofalo@pvsc.com";
MailMessage message = new MailMessage(from, toEmail);
message.Subject = "Employee Time Off Request";
message.Body = "Employee has request time off. Please click on the following link to access their time off request form."
+
Environment.NewLine + Environment.NewLine;message.Body +=
"http://.aspx?id=" + employeeDataId; SmtpClient mailClient = new SmtpClient("pv-exch01.pvsc.com");mailClient.Credentials = System.Net.
CredentialCache.DefaultNetworkCredentials;mailClient.Send(message);
}
I'm Kinda stuck and on a deadline, please help.
Thanks, JanisTo of MailMessage can contain MailAddresses Collection or comma separated address. Use following code
MailMessage message = new MailMessage(); ms.From = New MailAddress(from); //To can contain MailAddressCollection or comma separated address ms.To.Add("first@domain.com, second@domain.com");