选择显示字体大小

用asp实现支持附件的email系统(3)

     尝试发送邮件,但是失败了,请修改错误后重试!
  
  <script language="javascript">
  alert("您输入的收件组格式错误!\r正确的格式是:'gr:001'");
  history.back();
  </script>
  <p>
  <%
  response.end
  else
  thegroup=(mid(trim(strfieldvalue),4))
  end if
  end if
  
  tmpsql="select * from t_group where owner='"&session("myid")&"' and groupidowner='"&thegroup&"'"
  'response.write tmpsql
  set tmprs=server.createobject("adodb.recordset")
  tmprs.open tmpsql,conn
  if tmprs.bof or tmprs.eof then
  '没有找到该组
  %>
  尝试发送邮件,但是失败了,请修改错误后重试!
  <script language="javascript">
  alert("您输入的收件组<%=thegroup%>没有找到!");
  history.back();
  </script>
  <p>
  <%
  response.end
  else
  if tmprs("personnum")=0 then
  '组内没有用户
  %>
  尝试发送邮件,但是失败了,请修改错误后重试!
  <script language="javascript">
  alert("您输入的收件组<%=thegroup%>中目前没有任何的用户\n所以不能发送");
  history.back();
  </script>
  <p>
  <%
  response.end
  else
  strfieldvalue=trim(tmprs("groupempl"))
  tmprs.close
  set tmprs=nothing
  end if
  end if
  end if
  
  if instr(strfieldvalue,"") then
  '组发
  allsearch=replace(trim(strfieldvalue),"","','")
  allsearch="'"&allsearch&"'"
  tmpstring=trim(strfieldvalue)&""
  tosearch=""
  do while len(tmpstring)>=5
  
  tosearch=left(tmpstring,5)
  tmpstring=mid(tmpstring,7)
  if instr(tosearch,"") then
  '格式错误
  %>
  尝试发送邮件,但是失败了,请修改错误后重试!
  <script language="javascript">
  alert("您输入的收件人格式错误!");
  history.back();
  </script>
  <p>
  <%
  response.end
  end if
  
  tmpsql="select * from (select userid from t_officer where userid in ("&allsearch&")) derivedtbl where userid='"&tosearch&"'"
  'response.write tmpsql
  set tmprs=server.createobject("adodb.recordset")
  tmprs.open tmpsql,conn
  if tmprs.eof or tmprs.bof then
  %>
  尝试发送邮件,但是失败了,请修改错误后重试!
  <script language="javascript">
  alert("您输入的收件人<%=tosearch%>没有找到!");
  history.back();
  </script>
  <p>
  <%
  response.end
  end if
  tmprs.close
  set tmprs=nothing
  loop
  strfieldvalue=trim(strfieldvalue)
  
  else
  if len(trim(strfieldvalue))<>5 then
  '格式不正确
  %>
  尝试发送邮件,但是失败了,请修改错误后重试!
  <script language="javascript">
  alert("您输入的收件人<%=trim(strfieldvalue)%>不正确!");
  history.back();
  </script>
  <p>
  <%
  response.end
  else
  if isnumeric(trim(len(strfieldvalue))) then
  
  
  tmpsql="select * from t_officer where userid='"&trim(strfieldvalue)&"'"
  
  set tmprs=server.createobject("adodb.recordset")
  tmprs.open tmpsql,conn
  if tmprs.eof or tmprs.bof then
  %>
  尝试发送邮件,但是失败了,请修改错误后重试!
  <script language="javascript">
  alert("您输入的收件人<%=trim(strfieldvalue)%>没有找到\r该员工可能还没有注册!");
  history.back();
  </script>
  <p>
  <%
  response.end
  end if
  tmprs.close
  set tmprs=nothing
  
  
  strfieldvalue=trim(strfieldvalue)
  else
  %>
  尝试发送邮件,但是失败了,请修改错误后重试!
  <script language="javascript">
  alert("您输入的收件人<%=trim(strfieldvalue)%>不正确!");
  history.back();
  </script>
  
  <p> <%
  response.end
  end if
  end if
  end if
  
  end if
  strfieldvalue=replace(strfieldvalue,"<","<")
  'response.write strfieldname
  rs(strfieldname)=replace(strfieldvalue,">",">")
  
  binhttpheader=midb(binhttpheader,instrb( datastart + 1, binhttpheader, divider ))
  
  loop
  '开始处理文件数据
  
  
  titem=0
  rs("filesize_1")=0
  rs("filesize_2")=0
  rs("filesize_3")=0
  
  
  
  do while lenb(binhttpheader)>46
  
  if instrb( binhttpheader, bncrlf & bncrlf )<>0 then
  binheaderdata = leftb(binhttpheader,instrb( binhttpheader, bncrlf & bncrlf )-1)
  else
  exit do
  end if
  strheaderdata=bin2str(binheaderdata)
  
  
  '读取上传文件的content-type
  lngfilecontenttypestart=instr(strheaderdata,"content-type:")+len("content-type:")
  strfilecontenttype=trim(mid(strheaderdata,lngfilecontenttypestart))
  strfilecontenttype=replace(strfilecontenttype,vbcrlf,vbnullstring)
  
  '读取上传的文件名
  if instr(strheaderdata,"filename=")>0 then
  lngfilenamestart=instr(strheaderdata,"filename="&chr(34))+len("filename="&chr(34))
  lngfilenameend=instr(lngfilenamestart,strheaderdata,chr(34))
  strfilename=mid(strheaderdata,lngfilenamestart,lngfilenameend-lngfilenamestart)
  strfilename=trim(strfilename)
  strfilename=replace(strfilename,vbcrlf,vbnullstring)
  else
  strfilename=""
  end if
  
  '读取上传文件数据
  datastart = instrb( binhttpheader, bncrlf & bncrlf ) + 4
  dataend = instrb( datastart + 1, binhttpheader, divider ) - datastart
  
  if strfilename<>"" then
  if dataend>0 then
  binfieldvalue=midb( binhttpheader, datastart, dataend )
  '将上传的文件写入数据库
  titem=titem+1
  'response.write "titem:"&titem
  rs("filecontenttype_"&titem)=strfilecontenttype
  rs("filecontent_"&titem).appendchunk binfieldvalue
  rs("filesize_"&titem)=lenb(binfieldvalue)
  rs("filename_"&titem)=strfilename
  
  else
  binfieldvalue=binhttpheader
  end if
  
  end if
  
  if instrb( datastart + 1, binhttpheader, divider )>0 then
  binhttpheader=midb(binhttpheader,instrb( datastart + 1, binhttpheader, divider ))
  else
  binhttpheader=""
  end if
  
  loop
  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"))
  if csng(rs("sizetotal"))>=csng(2*1024*1024) then
  response.write "对不起,文件太大,请保证每封邮件的总大小不超过2m!"
  response.end
  end if
  rs("mailtime")=now
  rs("readerempl")=""
  if rs("receempl")<>"" then
  rs("receempl")=session("myid")
  rs("readerempl")=session("myid")
  end if
  rs("deleempl")=""
  rs("deleverempl")=""
  rs("sendmac")=strmac
  rs.update
  rs.close
  set rs=nothing
  conn.close
  set conn=nothing
  
  %>
  <script language=javascript
  window.open("mailok.asp",target="_self")
  </script>
  </body></html
  
    最后,我们来讲讲如何把内容从数据库中读出来,内容有这么几类,一类是浏览器上可以显示的,例如*.htm,一类是需要下载的,例如*.exe,还有一种是浏览器可以显示但是不能够让他显示的,例如*.asp,请看代码:
  
  <%
  response.buffer= true
  response.clear
  
  function getname(oriname)
  thename=oriname
  do while instr(thename,"/")>0
  thename=mid(thename,instr(thename,"/")+1)
  loop
  do while instr(thename,"\")>0
  thename=mid(thename,instr(thename,"\")+1)
  loop
  getname=thename
  
  end function
  
  function canexec(thechar)
  if instr(thechar,".asp")>0 then
  canexec=false
  exit function
  end if
  if instr(thechar,".asa")>0 then
  canexec=false
  exit function
  end if
  if instr(thechar,".aspx")>0 then
  canexec=false
  exit function
  end if
  if instr(thechar,".asax")>0 then
  canexec=false
  exit function
  end if
  canexec=true
  end function
  mailid=request("mailid")
  se=request("se")
  if se<>1 and se<>2 and se<>3 then
  response.end
  end if
  set conn=server.createobject("adodb.connection")
  set rs=server.createobject("adodb.recordset")
  conn.open "dsn=;uid=;pwd="
  sql="select * from t_mail where ((geterempl like '%"&session("myid")&"%' or deleempl like '%"&session("myid")&"%' or receempl like '%"&session("myid")&"%' ) and (not deleverempl like '%"&session("myid")&"%')) and mailid='"&mailid&"' "
  rs.open sql,conn,3,3
  if rs.eof or rs.bof then
  response.end
  end if
  if rs("filecontenttype_"&trim(se))<>"text/plain" or (not canexec(getname(trim(rs("filename_"&trim(se)))))) then
  response.contenttype = rs("filecontenttype_"&trim(se))
  end if
  
  
  
  'response.addheader "content-type","application/x-msdownload"
  
  if instr(response.contenttype,"application")>0 then
  response.addheader "content-disposition","attachment;filename="&getname(trim(rs("filename_"&trim(se))))
  end if
  response.binarywrite rs("filecontent_"&trim(se))
  rs.close
  set rs=nothing
  conn.close
  set conn=nothing
  %>
  
    文章到这里就结束了,至于邮件数据库的数据结构大家根据代码自己琢磨吧!  


 


关键字 本文所属关键字

相关 与本文相关文章

分类 所有文章关键字导航

源码编程相关

Java   Asp   PHP   .Net   XML   C/C++   CGI   VB   Jsp   J2ee   J2se   J2me   EJB   Servlet   Tomcat   Resin   Struts   Weblogic   Eclipse   ANT   GUI   JMS   Web servise   IDEA   Webphere   Hibernate   Spring   Jboss   Applet   Swing   Socket   Javamail   Perl   Ajax   P2P   安全   模式   框架   测试   开源   游戏

SQL数据库相关

My-SQL   Ms-SQL   Access   DB2   Oracle   Sybase   SQLserver   索引   存储过程   加密   数据库   分页   视图  

手机无线相关

3G   Wap   CDMA   GRPS   GSM   IVR   彩信   短信   无线   增值业务

网页设计制作相关

HTML   CSS   网页配色   网页特效   Javascript   VBscript   Dreamweaver   Frontpage   JS   Web   网站设计

网站建设推广相关

建站经验   网站优化   网站排名   推广   Alexa

操作系统/服务器相关

Windows XP   Windows 2000   Windows 2003   Windows Me   Windows 9.x   Linux   UNIX   注册表   操作系统   服务器   应用服务器

图形图像多媒体相关

Photoshop   Fireworks   Flash   Coreldraw   Illustrator   Freehand   Photoimpact   多媒体   图形图像

标准 网站致力的规范

Valid CSS!

无不良内容,无不良广告,无恶意代码

Valid XHTML 1.0 Transitional

creativecommons