我有一个 HTML 表单,在提交时会发送一封包含此代码的电子邮件。我如何将上传的文件作为附件发送。我是 ASP 新手,看过很多例子,但它们都非常不同且复杂。非常感谢。
HTML
<form method="post" action="index.asp">
<input type="text" name="name" id="name">
<input type="file" name="myFile1" id="myFile1">
<input type="submit" value="Submit">
</form>
ASP
<%
Set myMail=CreateObject("CDO.Message")
myMail.Subject="Sending email with CDO"
myMail.From="<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="c8a5b1a5a9a1a488a5b1aca7a5a9a1a6e6aba7a5" rel="noreferrer noopener nofollow">[email protected]</a>"
myMail.To="<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="d1a2bebcb4bebfb491a2bebcb4b5bebcb0b8bfffb2bebc" rel="noreferrer noopener nofollow">[email protected]</a>"
myMail.TextBody="This is a message."
myMail.AddAttachment "c:\mydocuments\test.txt"
myMail.Send
set myMail=nothing
%>
所以我得到了上面的代码来发送附件,但我仍然不知道如何从我的表单附加上传的文件?任何帮助将不胜感激。
最佳答案
您需要使用 SaveAs 或 InputStream 将任何内容添加到附件中。
Here is a link参见 MSDN 文档。
这是一种将文件附加到邮件的方法。
message.Attachments.Add(new Attachment(saveLocation, MediaTypeNames.Application.Octet))
关于asp-classic - ASP 发送带附件的电子邮件表单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15278123/