如何将多个文件附加到发送电子邮件。
我使用以下方法发送电子邮件。
public static void sendMail(string to, string from, string password, string subject, string body, int dep_code)
{
MailMessage mail = new MailMessage();
SmtpClient smtp = new SmtpClient();
if (to == "")
to = "-------";
MailAddressCollection m = new MailAddressCollection();
m.Add(to);
mail.Subject = subject;
mail.From = new MailAddress(from);
string banneredBody = @"<table width='100%' border='0' dir='rtl'>" +
"<tr>" +
"<td align='center'><img src=cid:Image1 /></td>" +
"</tr>" +
"<tr>" +
"<td align='center'>" + body + "</td>" +
"</tr>" +
"</table>";
mail.Body = banneredBody;
//mail.Body = body;
mail.IsBodyHtml = true;
mail.ReplyTo = new MailAddress(from);
mail.To.Add(m[0]);
smtp.Host = "....";
smtp.Port = 25;
smtp.EnableSsl = false;
smtp.Credentials = new System.Net.NetworkCredential(from, password);
ServicePointManager.ServerCertificateValidationCallback = delegate(object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { return true; };
smtp.Send(mail);
}
如何传递文件参数来附加它们。
我使用RadAsyncUpload:
private List<Telerik.Web.UI.UploadedFileInfo> uploadedFiles = new List<Telerik.Web.UI.UploadedFileInfo>();
public List<Telerik.Web.UI.UploadedFileInfo> UploadedFiles
{
get { return uploadedFiles; }
set { uploadedFiles = value; }
}
private void PopulateUploadedFilesList()
{
foreach (UploadedFile file in rad_upload.UploadedFiles)
{
UploadedFileInfo uploadedFileInfo = new UploadedFileInfo(file);
UploadedFiles.Add(uploadedFileInfo);
}
}