请告诉我使用telerik rad upload在邮件中附加文件并发送邮件。我尝试了不同的方案将文件附加到邮件中,但没有附加。
这是场景:我使用目标文件夹将其保存在网络服务器上并从该位置附加文件。
if (rdtxtAdditionalEmail.Text != "")
{
char[] delimiterChars = { ';' };
string text = rdtxtAdditionalEmail.Text;
string[] words = text.Split(delimiterChars);
foreach (string s in words)
{
newEmail.To = dr["Email"].ToString();
newEmail.From = "sy@mydomain.com";
newEmail.Subject = rdtxtSubject.Text;
newEmail.BodyFormat = MailFormat.Html;
newEmail.Body = rdtxtSubject.Text;
List<EmailAttachment> attachments = new List<EmailAttachment>();
foreach (EmailAttachment attach in attachments)
{
System.Net.Mail.Attachment attachFile = new Attachment("C:/Inetpub /wwwroot/DotNetNuke/Data/" + attach.fileName);
newEmail.Attachments.Add(attachFile);
}
for (int i = 0; i < rdauAttachments.UploadedFiles.Count; i++)
{
UploadedFile file = rdauAttachments.UploadedFiles[i];
EmailAttachment attachment = new EmailAttachment();
attachment.filePath = "C:/Inetpub/wwwroot/DotNetNuke/Data/" + rdauAttachments.UploadedFiles[i].GetName();
attachment.fileName = rdauAttachments.UploadedFiles[i].GetName();
newEmail.Attachments.Add(attachment);
}
SmtpMail.Send(newEmail);
}
}
我也尝试使用 Telerik 页面中的演示示例来执行此操作,但它没有锻炼。请帮我。
谢谢, 色拉万提