<%@ import namespace="system.IO"%>
<%@ import namespace="system.web.mail"%>
<script language="vb" runat="server">
sub enter_click(sender as object,e as eventargs)
dim filename as string
dim filepath as string
filename=path.getfilename(uploadfile.value)
filepath="c:\inetpub\wwwroot\asp.net\chapter3\upload\" & filename
uploadfile.postedfile.saveas(filepath)
dim objmail as new mailmessage
objmail.from=mailfrom.text
objmail.to=mailto.text
objmail.subject=subject.text
dim objattach as new mailattachment(filepath)
objmail.attachments.add(objattach)
smtpmail.smtpserver=""
smtpmail.send(objmail)
message.text="发送成功"
end sub
</script>
<html>
<body>
<h2>在线发送e-mail</h2>
<form runat="server">
发信人:<asp:textbox id="mailfrom" runat="server"/><br>
收信人:<asp:textbox id="mailto" runat="server"/><br>
主 题: <asp:textbox id="subject" runat="server"/><br>
内容: <asp:textbox id="body" textmode="multiline" rows="4" cols="40" runat="server"/><br>
附件: <input type="file" id="uploadfile" runat="server"/><br>
<asp:button id="enter" text="发送" onclick="enter_click" runat="server"/>
<br><asp:label id="message" runat="server"/>
<asp:label id="message1" runat="server"/>
</form>
</body>
</html>
每个人都他妈的那么开心,为什么我就不行!