我需要根据模板 NewsletterTemplate.aspx 文件发送电子邮件通讯。
我需要将 ArticleID 和 Language 传递给文件夹“_admin”下的 NewsletterTemplate.aspx 文件。
出于某种原因,它给了我以下错误
System.ArgumentException: Illegal characters in path.
,如果我从中删除 QueryString 部分,URL
那么它不会产生任何错误,但我无法提取文章
下面是代码示例。我将不胜感激这方面的帮助
String to, subject, message;
bool isHtml;
isHtml = true;
to = txtEmail.Text;
subject = txtEmailSubject.Text;
ListDictionary replacements = new ListDictionary();
string MessageBody = String.Empty;
string filePath = System.Web.HttpContext.Current.Request.PhysicalApplicationPath;
//String TemplatePath = "\_admin\NewsletterTemplate.aspx?ArticleID=" + ddArticleList.SelectedItem.Value.ToString() + "&Language=1";
using (StreamReader sr = new StreamReader(filePath + @"\_admin\NewsletterTemplate.aspx?ArticleID=" + ddArticleList.SelectedItem.Value.ToString() + "&Language=1"))
{
MessageBody = sr.ReadToEnd();
}
MailDefinition mailDef = new MailDefinition();
MailMessage msgHtml = mailDef.CreateMailMessage(to, replacements, MessageBody, new System.Web.UI.Control());
message = msgHtml.Body.ToString();
//send Email
Helper.SendEmailNewsletter(to, subject, message, isHtml);