4
任何人都可以整理下面的代码,以便将附件添加到电子邮件作品中。将附件添加到电子邮件
感谢
<%@ Page Language="VB" ContentType="text/html" ResponseEncoding="ISO-8859-1" Debug="true" %>
<% @Import Namespace="System.Web.Mail" %>
<% @Import Namespace="IO" %>
<script language="vb" runat="server">
Sub btnSendEmail_Click(sender as Object, e as EventArgs)
Dim objMM as New MailMessage()
objMM.To = "[email protected]"
objMM.From = "[email protected]"
objMM.BodyFormat = MailFormat.HTML
objMM.Priority = MailPriority.Normal
objMM.Subject = "Attachment test"
objMM.Body = "There should be an attachment with this email"
objMM.Attachments.Add(new MailAttachment("myimage.jpg"))
SmtpMail.SmtpServer = "localhost"
SmtpMail.Send(objMM)
End Sub
</script>
<html>
<head>
</head>
<body>
<form runat="server">
<asp:Button runat="server" id="btnSendEmail" Text="Send email" OnClick="btnSendEmail_Click" />
</form>
</body>
</html>
+1良好的发现 - 我什至没有发现... – PhilPursglove 2010-09-24 10:30:26
感谢您的...我是.net新手,所以这样的事情非常感谢。 – Tom 2010-09-24 10:34:01
好的......所以看起来采取这条建议会在代码的TO,FROM,BodyFormat,Attachment和SMTP部分创建所有其他错误的方式......任何人都可以指出我正确的方向来解决这些问题新问题? – Tom 2010-09-24 11:01:53