я создаю веб-форму, которая требует, чтобы пользователь выложил файл в формате doc, docxorpdf.
при отправке форма отправляется на адрес электронной почты вместе с приложенным файлом, ihave успешно осуществил отправку формы на адрес электронной почты, но не знает, как прикрепить к ней файл ... plz help
public void ProcessRequest(HttpContext context)
{
string template = context.Request["template"];
string responseHtml = BuiltTemplateHtml(context.Request, template, "response", false);
string reuestEmailHtml = BuiltTemplateHtml(context.Request, template, "request_email", false);
string contactEmail = GetTagsInnerText(reuestEmailHtml, "to", 0);
string contactName = GetTagsInnerText(reuestEmailHtml, "toname", 0);
string responEmailHtml = BuiltTemplateHtml(context.Request, template, "response_email", true, "contactName", contactName, "contactEmail", contactEmail);
sendEmail(reuestEmailHtml);
sendEmail(responEmailHtml);
context.Response.ContentType = "text/html";
context.Response.Write(responseHtml);
SaveAttachments(context, reuestEmailHtml);
}
private void SaveAttachments(HttpContext context, string settingFile)
{
if (context.Request.Files.Count > 0)
{
string fileNameformat = GetTagsInnerText(settingFile, "fileNameformat", 0);
string[] savefiles = GetTagsInnerText(settingFile, "savefiles", 0).Split('|', ',');
string[] allowextensions = GetTagsInnerText(settingFile, "allowextensions", 0).Split('|', ',');
string path = cleanPath(fileNameformat);
MailMessage mail = new MailMessage();
// attachment code here
}
}