使用asp实现支持附件的邮件系统(二).htm
来自「较为详细的介绍了asp自定义的各种函数,方便asp的各种开发.」· HTM 代码 · 共 479 行 · 第 1/3 页
HTM
479 行
<BR>else<BR>if tmprs("personnum")=0
then<BR>'组内没有用户<BR>%><BR>尝试发送邮件,但是失败了,请修改错误后重试! <BR><script
language="javascript"><BR>alert("您输入的收件组<%=thegroup%>中目前没有任何的用户\n所以不能发送");<BR>history.back();<BR></script><BR><p><BR><%<BR>response.end<BR>else<BR>strFieldValue=trim(tmprs("groupempl"))<BR>tmprs.close<BR>set
tmprs=nothing<BR>end if<BR>end if<BR>end if</P>
<P>if instr(strfieldValue,"|")
then<BR>'组发<BR>allsearch=replace(trim(strfieldValue),"|","','")<BR>allsearch="'"&allsearch&"'"<BR>tmpstring=trim(strfieldValue)&"|"<BR>tosearch=""<BR>do
while len(tmpstring)>=5
<BR><BR>tosearch=left(tmpstring,5)<BR>tmpstring=mid(tmpstring,7)<BR>if
instr(tosearch,"|") then<BR>'格式错误
<BR>%><BR>尝试发送邮件,但是失败了,请修改错误后重试! <BR><script
language="javascript"><BR>alert("您输入的收件人格式错误!");<BR>history.back();<BR></script><BR><p><BR><%<BR>response.end
<BR>end if</P>
<P>tmpSQL="select * from (select userid from t_officer where
userid in ("&allsearch&")) DERIVEDTBL where
userid='"&tosearch&"'" <BR>'response.write tmpsql<BR>set
tmprs=server.CreateObject("ADODB.Recordset")<BR>tmprs.Open
tmpsql,conn<BR>if tmprs.eof or tmprs.bof
then<BR>%><BR>尝试发送邮件,但是失败了,请修改错误后重试! <BR><script
language="javascript"><BR>alert("您输入的收件人<%=tosearch%>没有找到!");<BR>history.back();<BR></script><BR><p><BR><%<BR>response.end
<BR>end if<BR>tmprs.close<BR>set tmprs=nothing<BR>loop
<BR>strfieldValue=trim(strFieldValue)<BR><BR>else <BR>if
len(trim(strFieldValue))<>5
then<BR>'格式不正确<BR>%><BR>尝试发送邮件,但是失败了,请修改错误后重试! <BR><script
language="javascript"><BR>alert("您输入的收件人<%=trim(strFieldValue)%>不正确!");<BR>history.back();<BR></script><BR><p><BR><%<BR>response.end
<BR>else <BR>if isnumeric(trim(len(strFieldValue))) then<BR></P>
<P>tmpSQL="select * from t_officer where
userid='"&trim(strFieldValue)&"'" <BR><BR>set
tmprs=server.CreateObject("ADODB.Recordset")<BR>tmprs.Open
tmpsql,conn<BR>if tmprs.eof or tmprs.bof
then<BR>%><BR>尝试发送邮件,但是失败了,请修改错误后重试! <BR><script
language="javascript"><BR>alert("您输入的收件人<%=trim(strFieldValue)%>没有找到\r该员工可能还没有注册!");<BR>history.back();<BR></script><BR><p><BR><%<BR>response.end
<BR>end if<BR>tmprs.close<BR>set
tmprs=nothing<BR><BR><BR>strfieldValue=trim(strFieldValue)<BR>else<BR>%><BR>尝试发送邮件,但是失败了,请修改错误后重试!
<BR><script
language="javascript"><BR>alert("您输入的收件人<%=trim(strFieldValue)%>不正确!");<BR>history.back();<BR></script><BR><BR><p>
<%<BR>response.end <BR>end if<BR>end if<BR>end if<BR><BR>end
if<BR>strFieldValue=replace(strFieldValue,"<","<")<BR>'response.write
strfieldname<BR>rs(STRFIELDNAME)=replace(strFieldValue,">",">")<BR><BR>binHTTPHeader=MIDB(binHTTPHeader,INSTRB(
DataStart + 1, binHTTPHeader, divider
))<BR><BR>loop<BR>'开始处理文件数据</P>
<P></P>
<P>titem=0<BR>rs("filesize_1")=0<BR>rs("filesize_2")=0<BR>rs("filesize_3")=0</P>
<P><BR><BR>Do while lenB(binHTTPHeader)>46</P>
<P>if INSTRB( binHTTPHeader, bnCRLF & bnCRLF )<>0
then<BR>binHeaderData = LeftB(binHTTPHeader,INSTRB( binHTTPHeader,
bnCRLF & bnCRLF )-1)<BR>else<BR>exit do<BR>end if
<BR>strHeaderData=bin2str(binHeaderData)<BR><BR><BR>'读取上传文件的Content-Type<BR>lngFileContentTypeStart=Instr(strHeaderData,"Content-Type:")+Len("Content-Type:")<BR>strFileContentType=Trim(Mid(strHeaderData,lngFileContentTypeStart))<BR>strFileContentType=Replace(strFileContentType,vbCRLF,vbNullString)<BR><BR>'读取上传的文件名<BR>if
instr(strheaderdata,"filename=")>0
then<BR>lngFileNameStart=Instr(strHeaderData,"filename="&chr(34))+Len("filename="&chr(34))<BR>lngFileNameEnd=Instr(lngFileNameStart,strHeaderData,chr(34))<BR>strFileName=Mid(strHeaderData,lngFileNameStart,lngFileNameEnd-lngFileNameStart)<BR>strFileName=Trim(strFileName)<BR>strFileName=Replace(strFileName,vbCRLF,vbNullString)<BR>else<BR>strfilename=""<BR>end
if<BR><BR>'读取上传文件数据<BR>DataStart = INSTRB( binHTTPHeader, bnCRLF
& bnCRLF ) + 4 <BR>DataEnd = INSTRB( DataStart + 1,
binHTTPHeader, divider ) - DataStart<BR><BR>If
strFileName<>"" Then<BR>if dataend>0 then
<BR>binFieldValue=MIDB( binHTTPHeader, DataStart, DataEnd
)<BR>'将上传的文件写入数据库<BR>titem=titem+1<BR>'response.write
"titem:"&titem<BR>rs("FileContentType_"&titem)=strFileContentType<BR>rs("FileContent_"&titem).AppendChunk
binFieldValue<BR>rs("filesize_"&titem)=lenb(binFieldValue)<BR>rs("filename_"&titem)=strfilename</P>
<P>else<BR>binfieldvalue=binhttpheader<BR>end if </P>
<P>End if</P>
<P>if INSTRB( DataStart + 1, binHTTPHeader, divider )>0
then<BR>binHTTPHeader=MIDB(binHTTPHeader,INSTRB( DataStart + 1,
binHTTPHeader, divider ))<BR>else<BR>binhttpheader=""<BR>end
if<BR><BR>loop<BR>rs("sizetotal")=csng(rs("filesize_1"))+csng(rs("filesize_2"))+csng(rs("filesize_3"))+csng(len(rs("body")))+csng(len(rs("emailtitle")))+csng(len(rs("emailshowname")))+csng(len("geterempl"))<BR>if
csng(rs("sizetotal"))>=csng(2*1024*1024) then<BR>response.write
"对不起,文件太大,请保证每封邮件的总大小不超过2M!"<BR>response.end <BR>end if
<BR>rs("mailtime")=now<BR>rs("readerempl")=""<BR>if
rs("receempl")<>""
then<BR>rs("receempl")=session("myid")<BR>rs("readerempl")=session("myid")<BR>end
if<BR>rs("deleempl")=""
<BR>rs("deleverempl")=""<BR>rs("sendmac")=strmac<BR>rs.update
<BR>rs.close<BR>set rs=Nothing<BR>conn.Close<BR>set conn=Nothing
</P>
<P>%> <BR><script
language=javascript><BR>window.open("mailok.asp",target="_self")<BR></script><BR></body></html>
<BR><BR></P></BLOCKQUOTE></TD></TR>
<TR>
<TD class=p4 vAlign=top width="50%">
<BLOCKQUOTE>原作者:sonic_qd<BR>来 源:开发者俱乐部<BR>共有4238位读者阅读过此文<BR>【<A
href="http://bbs.aspsky.net/list.asp?boardid=1">发表评论</A>】
</BLOCKQUOTE></TD>
<TD class=p4 vAlign=top width="50%">
<P>
<LI><FONT color=#0772b1>上篇文章</FONT>:<A
href="http://www.aspsky.net/article/list.asp?id=2615">使用asp实现支持附件的邮件系统(一)</A>
<BR>
<LI><FONT color=#0772b1>下篇文章</FONT>:<A
href="http://www.aspsky.net/article/list.asp?id=2617">使用asp实现支持附件的邮件系统(三)</A>
</LI></TD></TR>
<TR>
<TD bgColor=#297dff class=p4 height=20 width="50%"><FONT
color=#ceffff> → 本周热门</FONT></TD>
<TD bgColor=#297dff class=p4 width="50%"><FONT color=#ceffff> →
相关文章</FONT></TD></TR>
<TR>
<TD bgColor=#586011 colSpan=2 height=1><SPACER type="block"
width="1"></TD></TR>
<TR>
<TD colSpan=2 height=7></TD></TR>
<TR>
<TD class=p4 vAlign=top width="50%">
<LI><A href="http://www.aspsky.net/article/list.asp?id=1510"
target=_top title="SQL Server 7.0 入门(一)">SQL Server 7.0
入门(...</A>[<FONT color=red>7239</FONT>]<BR>
<LI><A href="http://www.aspsky.net/article/list.asp?id=1540"
target=_top title=PHP4实际应用经验篇(1)>PHP4实际应用经验篇(1)</A>[<FONT
color=red>7135</FONT>]<BR>
<LI><A href="http://www.aspsky.net/article/list.asp?id=1536"
target=_top
title=无组件文件上传代码实例(支持多文件上传及文件和input域混合上传)>无组件文件上传代码实例(支持多文件上...</A>[<FONT
color=red>6029</FONT>]<BR>
<LI><A href="http://www.aspsky.net/article/list.asp?id=2557"
target=_top title=树型结构在ASP中的简单解决>树型结构在ASP中的简单解决</A>[<FONT
color=red>5757</FONT>]<BR>
<LI><A href="http://www.aspsky.net/article/list.asp?id=1545"
target=_top title=PHP4实际应用经验篇(6)>PHP4实际应用经验篇(6)</A>[<FONT
color=red>5599</FONT>]<BR>
<LI><A href="http://www.aspsky.net/article/list.asp?id=2563"
target=_top title=一个老个写的无组件上传>一个老个写的无组件上传</A>[<FONT
color=red>5013</FONT>]<BR>
<LI><A href="http://www.aspsky.net/article/list.asp?id=1542"
target=_top title=PHP4实际应用经验篇(3)>PHP4实际应用经验篇(3)</A>[<FONT
color=red>4731</FONT>]<BR></LI></TD>
<TD class=p4 vAlign=top width="50%">
<LI><A
href="http://www.aspsky.net/article/list.asp?id=2617">使用asp实现支持附件的邮件系统(三)</A><BR>
<LI><A
href="http://www.aspsky.net/article/list.asp?id=2616">使用asp实现支持附件的邮件系统(二)</A><BR>
<LI><A
href="http://www.aspsky.net/article/list.asp?id=2615">使用asp实现支持附件的邮件系统(一)</A><BR></LI></TD></TR>
<TR>
<TD colSpan=2 height=7></TD></TR></TBODY></TABLE>
<TD bgColor=#297dff width=1> </TD></TR></TBODY></TABLE>
<TABLE border=0 cellPadding=0 cellSpacing=0 width=755>
<TBODY>
<TR>
<TD bgColor=#297dff height=1><SPACER type="block"
width="1"></TD></TR></TBODY></TABLE>
<TABLE border=0 cellPadding=0 cellSpacing=0 width=755>
<TBODY>
<TR>
<TD align=middle height=30></TD></TR></TBODY></TABLE>
<TABLE border=0 cellPadding=0 cellSpacing=0 width=755>
<TBODY>
<TR>
<TD align=middle class=p2 width="100%">
<TABLE border=0 cellPadding=0 cellSpacing=0 width=755>
<TBODY>
<TR>
<TD align=middle class=p2 width="100%">
<P align=center><A
href="http://www.aspsky.net/produce/index.asp">客户服务</A> -- <A
href="http://www.aspsky.net/aspads.asp">广告合作</A> -- <A
href="http://www.aspsky.net/about.asp">关于本站</A> -- <A
href="http://www.aspsky.net/tell.asp">联系方法</A><BR><BR>动网先锋版权所有 <FONT
face=Verdana, size=1 Arial, Helvetica, sans-serif>Copyright ©
2000-2001 <B>AspSky<FONT color=#cc0000>.Net</FONT></B>, All Rights
Reserved .</FONT>
</P></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></CENTER></CENTER></BODY></HTML>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?