| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 447 人关注过本帖
标题:[求助]邮件发送的问题《vb》
只看楼主 加入收藏
tkgg888
Rank: 1
等 级:新手上路
帖 子:341
专家分:2
注 册:2006-4-24
收藏
 问题点数:0 回复次数:2 
[求助]邮件发送的问题《vb》

邮件发出去收不到,系统也不提示出错,为什么??
<%@ import namespace="system.web.mail" %>
<script language="vb" runat="server">
sub sendmsg(sender as object, e as imageclickeventargs)
dim objmail as new mailmessage()
objmail.from=fromwho.text & "<" & frommail.text & ">"
objmail.to=towho.text & "<" & tomail.text & ">"
select case bodyformat.selecteditem.text
case "html"
objmail.bodyformat=mailformat.html
case "text"
objmail.bodyformat=mailformat.text
end select
select case bodyencoding.selecteditem.text
case "UTF8"
objmail.bodyencoding=encoding.UTF8
case "UTF7"
objmail.bodyencoding=encoding.UTF7
case "ASCII"
objmail.bodyencoding=encoding.ASCII
case "unicode"
objmail.bodyencoding=encoding.unicode
end select
objmail.subject=subject.text
objmail.body=content.text
if filename.value<>"" then
dim attachfile as mailattachment
attachfile=new mailattachment(filename.postedfile.filename)
objmail.attachments.add(attachfile)
end if
smtpmail.smtpserver="163.com.cn"
smtpmail.send(objmail)
end sub
sub resetmsg(sender as object, e as imageclickeventargs)
fromwho.text=""
frommail.text=""
towho.text=""
tomail.text=""
subject.text=""
content.text=""
end sub
</script>
<html>
<head>
<title>邮件发送</title>
</head>
<body>
<center><asp:image runat="server" imageurl="title.jpg" /></center>
<form runat="server" enctype="text/plain">
<table width=80% align="center" cellspacing=0 cellpadding=3>
<tr bgcolor="#ffffa1">
<td width=17%>发件人</td>
<td width=25%>
<asp:textbox runat="server" id="fromwho" columns=7 />
</td>
<td colspan=2 width=58%>电子邮箱
<asp:textbox runat="server" id="frommail" columns=20 />
</td>
</tr>
<tr bgcolor="#fffff0">
<td>收件人</td>
<td><asp:textbox runat="server" id="towho" columns=7 /></td>
<td colspan=2>电子邮箱
<asp:textbox runat="server" id="tomail" columns=20 />
</td>
</tr>
<tr bgcolor="#ffffa1">
<td>邮件格式</td>
<td>
<asp:radiobuttonlist runat="server" id="bodyformat" repeatcolumns=2>
<asp:listitem text="html" value="html" selected="true" />
<asp:listitem text="text" value="text" />
</asp:radiobuttonlist>
</td>
<td>编码方式</td>
<td>
<asp:radiobuttonlist runat="server" id="bodyencoding" repeatcolumns=4>
<asp:listitem text="UTF8" value="UTF8" selected="true" />
<asp:listitem text="UTF7" value="UTF7" />
<asp:listitem text="ASCII" value="ASCII" />
<asp:listitem text="Unicode" value="Unicode"/>
</asp:radiobuttonlist>
</td>
</tr>
<tr bgcolor="#ffffa1">
<td>邮件主题</td>
<td colspan=3>
<asp:textbox runat="server" id="subject" columns=40 />
</td>
</tr>
<tr bgcolor="#fffff0">
<td>邮件内容</td>
<td colspan=3>
<asp:textbox runat="server" id="content" textmode="multiline" columns=45 rows=5 />
</td>
</tr>
<tr bgcolor="#ffffa1">
<td width=18%>附件</td>
<td colspan=3>
<input type="file" runat="server" id="filename" size=50 />
</td>
</tr>
</table>
<center>
<asp:imagebutton runat="server" imageurl="send.gif" onclick="sendmsg" />
<asp:imagebutton runat="server" imageurl="reset.gif" onclick="resetmsg" />
</center>
<asp:requiredfieldvalidator runat="server" controltovalidate="fromwho" errormessage="发件人" display="none" />
<asp:requiredfieldvalidator runat="server" controltovalidate="frommail" errormessage="发件人电子信箱" display="none" />
<asp:requiredfieldvalidator runat="server" controltovalidate="towho" errormessage="收件人" display="none" />
<asp:requiredfieldvalidator runat="server" controltovalidate="tomail" errormessage="收件人电子信箱" display="none" />
<asp:requiredfieldvalidator runat="server" controltovalidate="subject" errormessage="主题" display="none" />
<asp:requiredfieldvalidator runat="server" controltovalidate="content" errormessage="内容" display="none" />
<asp:validationsummary runat="server" displaymode="bulletlist" showmessagebox="true" showsummary="false" headertext="错误警告,以下字段不可为空:" />
</form>
</body>
</html>

搜索更多相关主题的帖子: 邮件 
2006-05-09 12:11
小笨笨
Rank: 5Rank: 5
等 级:贵宾
威 望:19
帖 子:1169
专家分:0
注 册:2006-4-17
收藏
得分:0 
163的服务器需要身份验证。你去下载我的发email的源代码程序看一下就知道了。

欢迎光临我的博客: http://smallfools.blog./default.html
2006-05-10 08:40
adu520
Rank: 1
等 级:新手上路
帖 子:28
专家分:0
注 册:2006-5-6
收藏
得分:0 

是吗


2006-05-10 12:32
快速回复:[求助]邮件发送的问题《vb》
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015769 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved