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