|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
减少客户内IT专业人才缺乏带来的影响。ASP的客户员工利用浏览器进入相关的应用软件,简单易用,无需专业技术支持。 人人常常切磋利用asp,而不利用其他组建可否完成文件的上传,从而开辟出撑持邮件附件的邮件体系,谜底是能够的。
以下是发送邮件的页面,邮件的帐号是员工号,假定是5位的数字,sendmail.asp固然是在正当上岸后才干够看到的
<html>
<head>
<metahttp-equiv="Content-Type"content="text/html;charset=gb2312">
<linkrel="stylesheet"type="text/CSS"href="/css/FORUM.CSS">
<styletype=text/css>
<!--
input{font-size:9pt;color:#0011dd;background-color:#e9e9f9;padding-top:0px}
select{font-size:9pt;color:#0011dd;background-color:#e9e9f9;padding-top:0px}
textarea{font-size:9pt;color:#0011dd;background-color:#e9e9f9;padding-top:0px}
-->
</style>
<title>邮件体系</title></head>
<bodybgcolor="#FEF7ED">
<scriptlanguage="javascript">
<%
ifsession("myid")=""orlen(session("myid"))<>5then
response.write"window.open(nolog.asp,target=_top);"
endif
%>
functioncheck(theform)
{
if(theform.geterempl.value==)
{
alert(请输出收件人!);
theform.geterempl.focus();
returnfalse;
}
if(theform.emailtitle.value==)
{
alert(请输出主题!);
theform.emailtitle.focus();
returnfalse;
}
if(theform.emailtitle.value.length>200)
{
alert(主题请少于200字节);
theform.emailtitle.focus();
returnfalse;
}
if(theform.body.value.length>15*1024)
{
alert(注释请少于16K);
theform.body.focus();
returnfalse;
}
if(theform.emailshowname.value.length>1024)
{
alert(署名请少于1K);
theform.emailshowname.focus();
returnfalse;
}
}
</script>
<%
meth=request.querystring("meth")
ifmeth=1then
geterempl=trim(request.querystring("geterempl"))
emailtitle=trim(request.querystring("emailtitle"))
elseifmeth=2then
mailid=trim(request.querystring("mailid"))
setconn=server.createobject("adodb.connection")
conn.open"DSN=;UID=;PWD="
dsnpath="DSN=;UID=;PWD="
setrs=server.createobject("adodb.recordset")
selectnew="select*fromt_mailwhere((geterempllike%"&session("myid")&"%ordeleempllike%"&session("myid")&"%orreceempllike%"&session("myid")&"%)and(notdeleverempllike%"&session("myid")&"%))andmailid="&mailid&""
rs.openselectnew,dsnpath,3,3
ifrs.boforrs.eofthen
%>
<scriptlanguage="javascript">
alert("您没有检察这封邮件的权限!");
window.history.back();
</script>
<%
response.end
else
body=rs("body")
emailtitle=rs("emailtitle")
rs.close
setrs=nothing
conn.close
setconn=nothing
endif
endif
%>
<Formname="upload_file"action="loadmail.asp"method=postenctype="multipart/form-data">
<tablewidth="100%"border="0"cellspacing="2"cellpadding="2">
<tr>
<tdwidth="11%">
<divalign="right">发件人:</div>
</td>
<tdwidth="89%">
<inputtype="hidden"name="senderempl"value="<%=session("myid")%>">
<%=session("myid")%></td>
</tr>
<tr>
<tdwidth="11%">
<divalign="right">收件人:</div>
</td>
<tdwidth="89%">
<inputtype="text"name="geterempl"size="40"value="<%=geterempl%>">
<inputtype="checkbox"name="emaillevel"value="1"style="background-color:#FEF7ED">
告急函件</td>
</tr>
<tr>
<tdwidth="11%"valign="top"></td>
<tdwidth="89%">发送多团体的时分可使用"<fontcolor="#9999FF">|</font>"离隔,比方:<fontcolor="#3399FF">01234|01235|01236</font>,第一名和最初一名不必要"<fontcolor="#9999FF">|</font>"
<fontcolor="#FF0000">新功效</font>:您能够把信信间接发送给您设定的<ahref="group.asp">某用户</a>,发送格局为:gr:组序号,比方<fontcolor="#0099FF">gr:001</font></td>
</tr>
<tr>
<tdwidth="11%">
<divalign="right"></div>
</td>
<tdwidth="89%">
<inputtype="checkbox"name="receempl"value="1"style="background-color:#FEF7ED">
保留一份到保藏夹[<fontcolor="#3399FF">选定此项,则邮件发送到对方邮箱的同时发送到本人的保藏夹里</font>]</td>
</tr>
<tr>
<tdwidth="11%"valign="top"></td>
<tdwidth="89%"></td>
</tr>
<tr>
<tdwidth="11%"align="right">主题:</td>
<tdwidth="89%">
<inputtype="text"name="emailtitle"size="60"value="<%=emailtitle%>">
</td>
</tr>
<tr>
<tdwidth="11%"valign="top">
<divalign="right">注释:</div>
</td>
<tdwidth="89%">
<TEXTAREAname=bodyrows=8cols=60><%=body%></TEXTAREA>
</td>
</tr>
<tr>
<tdwidth="11%"valign="top">
<divalign="right">署名:</div>
</td>
<tdwidth="89%">
<textareaname="emailshowname"cols="30"rows="6"><%=application(session("myid")&"_name")%></textarea>
</td>
</tr>
<tr>
<tdwidth="11%">
<divalign="right">
<inputtype=hiddenname="FileUploadStart">
附件1:</div>
</td>
<tdwidth="89%">
<inputtype="file"name="file_up"size="50">
</td>
</tr>
<tr>
<tdwidth="11%">
<divalign="right">附件2:</div>
</td>
<tdwidth="89%">
<inputtype="file"name="file_up1"size="50">
</td>
</tr>
<tr>
<tdwidth="11%">
<divalign="right">附件3:</div>
</td>
<tdwidth="89%">
<inputtype="file"name="file_up2"size="50">
<inputtype=hiddenname="FileUploadEnd">
</td>
</tr>
<tr>
<tdwidth="11%">
<divalign="right"></div>
</td>
<tdwidth="89%">
<inputtype=submitvalue=断定>
</td>
</tr>
</table>
</Form>
</body>
</html>
不外这仅仅只是失掉了发送者的ip地点和mac地点,并且克制用户本人变动本人ip地点的代码,由于我们的体系是必要对团体修正ip的举动举行克制的。
<%
strIP=Request.ServerVariables("REMOTE_ADDR")
Setnet=Server.CreateObject("wscript.network")
Setsh=Server.CreateObject("wscript.shell")
sh.run"%comspec%/cnbtstat-A"&strIP&">c:"&strIP&".txt",0,true
Setsh=nothing
Setfso=createobject("scripting.filesystemobject")
Setts=fso.opentextfile("c:"&strIP&".txt")
macaddress=null
DoWhileNotts.AtEndOfStream
data=ucase(trim(ts.readline))
Ifinstr(data,"MACADDRESS")Then
macaddress=trim(split(data,"=")(1))
ExitDo
EndIf
loop
ts.close
Setts=nothing
fso.deletefile"c:"&strIP&".txt"
Setfso=nothing
GetMACAddress=macaddress
strMac=GetMACAddress
setconn=server.CreateObject("adodb.connection")
conn.open"DSN=;UID=;PWD="
dsnpath="DSN=;UID=;PWD="
setrs=server.CreateObject("adodb.recordset")
sele="select*fromgetmacwhereg_mac="&strMac&""
rs.opensele,dsnpath
ifrs.bofthen
setconn=server.CreateObject("adodb.connection")
conn.open"DSN=;UID=;PWD="
dsnpath="DSN=;UID=;PWD="
setrs=server.CreateObject("adodb.recordset")
g_id=mid(strIP,9)
g_id=left(g_id,2)
response.writeg_id
ifisnumeric(g_id)then
g_id=cint(g_id)
else
g_id=0
endif
sele="insertintogetmac(g_ip,g_mac,g_id,g_ok)values("&strIP&","&strMac&","&g_id&",0)"
rs.opensele,dsnpath
else
setconn=server.CreateObject("adodb.connection")
conn.open"DSN=;UID=;PWD="
dsnpath="DSN=;UID=;PWD="
setrs=server.CreateObject("adodb.recordset")
sele="select*fromgetmacwhereg_ip="&trim(strIP)&"andg_mac="&trim(strMac)&""
rs.opensele,dsnpath
ifrs.boforrs.eofthen
setrs1=server.CreateObject("adodb.recordset")
sele="insertintobadmac(ip,mac,thetime)values("&strIP&","&strMac&","&now()&")"
rs1.opensele,dsnpath
response.redirect("/reg/wrong.asp")
response.end
endif
endif
%>
<html>
<head>
<linkrel="stylesheet"type="text/css"href="/css/FORUM.CSS">
<styletype=text/css>
<!--
input{font-size:9pt;color:#0011dd;background-color:#e9e9f9;padding-top:0px}
select{font-size:9pt;color:#0011dd;background-color:#e9e9f9;padding-top:0px}
textarea{font-size:9pt;color:#0011dd;background-color:#e9e9f9;padding-top:0px}
-->
</style>
<title>邮件体系</title></head><bodybgcolor="#FEF7ED">
<%
Response.Expires=0
Functionbin2str(binstr)
Dimvarlen,clow,ccc,skipflag
skipflag=0
ccc=""
IfNotIsNull(binstr)Then
varlen=LenB(binstr)
Fori=1Tovarlen
Ifskipflag=0Then
clow=MidB(binstr,i,1)
IfAscB(clow)>127Then
ccc=ccc&Chr(AscW(MidB(binstr,i+1,1)&clow))
skipflag=1
Else
ccc=ccc&Chr(AscB(clow))
EndIf
Else
skipflag=0
EndIf
Next
EndIf
bin2str=ccc
EndFunction
varByteCount=Request.TotalBytes
response.writevarbytecount
bnCRLF=chrB(13)&chrB(10)
binHTTPHeader=Request.BinaryRead(varByteCount)
response.writevbenter
response.write"
"&cstr(binhttpheader)&"
"
sread=0
eread=0
入手下手读非文件域的数据
setconn=Server.CreateObject("ADODB.Connection")
conn.open"DSN=;UID=;PWD="
SQL="select*fromt_mailwheremailid=0"
setrs=server.CreateObject("ADODB.Recordset")
rs.Opensql,conn,3,3
rs.addnew
rs("emaillevel")=0
rs("receempl")=""
DowhilelenB(binHTTPHeader)>46
Divider=LEFTb(binHTTPHeader,INSTRB(binHTTPHeader,bnCRLF)-1)
binHeaderData=Leftb(binHTTPHeader,INSTRB(binHTTPHeader,bnCRLF&bnCRLF)-1)
strHeaderData=bin2str(binHeaderData)
lngFieldNameStart=Instr(strHeaderData,"name="&chr(34))+Len("name="&chr(34))
response.write"
lngfieldnamestart:"&lngfieldnamestart
lngFieldNameEnd=Instr(lngFieldNameStart,strHeaderData,chr(34))
response.write"
lngfieldnameEND:"&lngfieldnameEND
strFieldName=Mid(strHeaderData,lngFieldNameStart,lngFieldNameEnd-lngFieldNameStart)
RESPOnSE.WRITE"<BR>STRFIELDNAME:"&STRfieldname
strFieldName=Trim(strFieldName)
strFieldName=Replace(strFieldName,vbcrlf,vbnullstring)
判别文件数据时分入手下手
IfstrComp(strFieldName,"FileUploadStart",1)=0andsread=0Then
response.write"找到了文件入手下手的中央"
sread=1
response.write"
"&INSTRB(DataStart+1,binHTTPHeader,divider)&"
"
binHTTPHeader=MIDB(binHTTPHeader,INSTRB(DataStart+1,binHTTPHeader,divider))
exitdo
Endif
DataStart=INSTRB(binHTTPHeader,bnCRLF&bnCRLF)+4
DataEnd=INSTRB(DataStart+1,binHTTPHeader,divider)-DataStart
binFieldValue=MIDB(binHTTPHeader,DataStart,DataEnd)
strFieldValue=bin2str(binFieldValue)
strFieldValue=Trim(strFieldValue)
strFieldValue=Replace(strFieldValue,"","")
非文件上传域变量赋值
executestrFieldName&"="""&strFieldValue&""""
response.writestrFieldName&":"&strFieldValue&"
"
ifstrfieldname="geterempl"then
strFieldValue=Replace(strFieldValue,vbcrlf,vbnullstring)
ifinstr(strfieldvalue,"gr:")=1then
邮件组发
response.writelen(trim(strfieldvalue))
iflen(trim(strfieldvalue))<>6then
格局毛病前往
%>
实验发送邮件,可是失利了,请修正毛病后重试!
<scriptlanguage="javascript">
alert("您输出的收件组格局毛病!准确的格局是:gr:001");
history.back();
</script>
<p>
<%
response.end
else
ifnotisnumeric(mid(trim(strfieldvalue),4))then
格局毛病前往
%>
实验发送邮件,可是失利了,请修正毛病后重试!
<scriptlanguage="javascript">
alert("您输出的收件组格局毛病!准确的格局是:gr:001");
history.back();
</script>
<p>
<%
response.end
else
thegroup=(mid(trim(strfieldvalue),4))
endif
endif
tmpSQL="select*fromt_groupwhereowner="&session("myid")&"andgroupidowner="&thegroup&""
response.writetmpsql
settmprs=server.CreateObject("ADODB.Recordset")
tmprs.Opentmpsql,conn
iftmprs.bofortmprs.eofthen
没有找到该组
%>
实验发送邮件,可是失利了,请修正毛病后重试!
<scriptlanguage="javascript">
alert("您输出的收件组<%=thegroup%>没有找到!");
history.back();
</script>
<p>
<%
response.end
else
iftmprs("personnum")=0then
组内没有效户
%>
实验发送邮件,可是失利了,请修正毛病后重试!
<scriptlanguage="javascript">
alert("您输出的收件组<%=thegroup%>中今朝没有任何的用户
以是不克不及发送");
history.back();
</script>
<p>
<%
response.end
else
strFieldValue=trim(tmprs("groupempl"))
tmprs.close
settmprs=nothing
endif
endif
endif
ifinstr(strfieldValue,"|")then
组发
allsearch=replace(trim(strfieldValue),"|",",")
allsearch=""&allsearch&""
tmpstring=trim(strfieldValue)&"|"
tosearch=""
dowhilelen(tmpstring)>=5
tosearch=left(tmpstring,5)
tmpstring=mid(tmpstring,7)
ifinstr(tosearch,"|")then
格局毛病
%>
实验发送邮件,可是失利了,请修正毛病后重试!
<scriptlanguage="javascript">
alert("您输出的收件品德式毛病!");
history.back();
</script>
<p>
<%
response.end
endif
tmpSQL="select*from(selectuseridfromt_officerwhereuseridin("&allsearch&"))DERIVEDTBLwhereuserid="&tosearch&""
response.writetmpsql
settmprs=server.CreateObject("ADODB.Recordset")
tmprs.Opentmpsql,conn
iftmprs.eofortmprs.bofthen
%>
实验发送邮件,可是失利了,请修正毛病后重试!
<scriptlanguage="javascript">
alert("您输出的收件人<%=tosearch%>没有找到!");
history.back();
</script>
<p>
<%
response.end
endif
tmprs.close
settmprs=nothing
loop
strfieldValue=trim(strFieldValue)
else
iflen(trim(strFieldValue))<>5then
格局不准确
%>
实验发送邮件,可是失利了,请修正毛病后重试!
<scriptlanguage="javascript">
alert("您输出的收件人<%=trim(strFieldValue)%>不准确!");
history.back();
</script>
<p>
<%
response.end
else
ifisnumeric(trim(len(strFieldValue)))then
tmpSQL="select*fromt_officerwhereuserid="&trim(strFieldValue)&""
settmprs=server.CreateObject("ADODB.Recordset")
tmprs.Opentmpsql,conn
iftmprs.eofortmprs.bofthen
%>
实验发送邮件,可是失利了,请修正毛病后重试!
<scriptlanguage="javascript">
alert("您输出的收件人<%=trim(strFieldValue)%>没有找到该员工大概还没有注册!");
history.back();
</script>
<p>
<%
response.end
endif
tmprs.close
settmprs=nothing
strfieldValue=trim(strFieldValue)
else
%>
实验发送邮件,可是失利了,请修正毛病后重试!
<scriptlanguage="javascript">
alert("您输出的收件人<%=trim(strFieldValue)%>不准确!");
history.back();
</script>
<p><%
response.end
endif
endif
endif
endif
strFieldValue=replace(strFieldValue,"<","<")
response.writestrfieldname
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
DowhilelenB(binHTTPHeader)>46
ifINSTRB(binHTTPHeader,bnCRLF&bnCRLF)<>0then
binHeaderData=LeftB(binHTTPHeader,INSTRB(binHTTPHeader,bnCRLF&bnCRLF)-1)
else
exitdo
endif
strHeaderData=bin2str(binHeaderData)
读取上传文件的Content-Type
lngFileContentTypeStart=Instr(strHeaderData,"Content-Type:")+Len("Content-Type:")
strFileContentType=Trim(Mid(strHeaderData,lngFileContentTypeStart))
strFileContentType=Replace(strFileContentType,vbCRLF,vbNullString)
读取上传的文件名
ifinstr(strheaderdata,"filename=")>0then
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=""
endif
读取上传文件数据
DataStart=INSTRB(binHTTPHeader,bnCRLF&bnCRLF)+4
DataEnd=INSTRB(DataStart+1,binHTTPHeader,divider)-DataStart
IfstrFileName<>""Then
ifdataend>0then
binFieldValue=MIDB(binHTTPHeader,DataStart,DataEnd)
将上传的文件写进数据库
titem=titem+1
response.write"titem:"&titem
rs("FileContentType_"&titem)=strFileContentType
rs("FileContent_"&titem).AppendChunkbinFieldValue
rs("filesize_"&titem)=lenb(binFieldValue)
rs("filename_"&titem)=strfilename
else
binfieldvalue=binhttpheader
endif
Endif
ifINSTRB(DataStart+1,binHTTPHeader,divider)>0then
binHTTPHeader=MIDB(binHTTPHeader,INSTRB(DataStart+1,binHTTPHeader,divider))
else
binhttpheader=""
endif
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"))
ifcsng(rs("sizetotal"))>=csng(2*1024*1024)then
response.write"对不起,文件太年夜,请包管每封邮件的总巨细不凌驾2M!"
response.end
endif
rs("mailtime")=now
rs("readerempl")=""
ifrs("receempl")<>""then
rs("receempl")=session("myid")
rs("readerempl")=session("myid")
endif
rs("deleempl")=""
rs("deleverempl")=""
rs("sendmac")=strmac
rs.update
rs.close
setrs=Nothing
conn.Close
setconn=Nothing
%>
<scriptlanguage=javascript>
window.open("mailok.asp",target="_self")
</script>
</body></html>
最初,我们来说讲怎样把内容从数据库中读出来,内容有这么几类,一类是扫瞄器上能够显现的,比方*.htm,一类是必要下载的,比方*.exe,另有一种是扫瞄器能够显现可是不克不及够让他显现的,比方*.asp,请看代码:
<%
Response.Buffer=true
Response.Clear
functiongetname(oriname)
thename=oriname
dowhileinstr(thename,"/")>0
thename=mid(thename,instr(thename,"/")+1)
loop
dowhileinstr(thename,"")>0
thename=mid(thename,instr(thename,"")+1)
loop
getname=thename
endfunction
functioncanexec(thechar)
ifinstr(thechar,".asp")>0then
canexec=false
exitfunction
endif
ifinstr(thechar,".asa")>0then
canexec=false
exitfunction
endif
ifinstr(thechar,".aspx")>0then
canexec=false
exitfunction
endif
ifinstr(thechar,".asax")>0then
canexec=false
exitfunction
endif
canexec=true
endfunction
mailID=request("mailID")
se=request("se")
ifse<>1andse<>2andse<>3then
response.end
endif
Setconn=server.createobject("adodb.connection")
setrs=server.createobject("adodb.recordset")
conn.open"DSN=;UID=;PWD="
sql="select*fromt_mailwhere((geterempllike%"&session("myid")&"%ordeleempllike%"&session("myid")&"%orreceempllike%"&session("myid")&"%)and(notdeleverempllike%"&session("myid")&"%))andmailid="&mailid&""
rs.opensql,conn,3,3
ifrs.eoforrs.bofthen
response.end
endif
ifrs("filecontenttype_"&trim(se))<>"text/plain"or(notcanexec(getname(trim(rs("filename_"&trim(se))))))then
Response.ContentType=rs("FileContentType_"&trim(se))
endif
Response.AddHeader"content-type","application/x-msdownload"
ifinstr(response.contenttype,"application")>0then
response.AddHeader"Content-Disposition","attachment;filename="&getname(trim(rs("filename_"&trim(se))))
endif
Response.BinaryWriters("FileContent_"&trim(se))
rs.close
setrs=Nothing
conn.close
setconn=nothing
%>
文章到这里就停止了,至于邮件数据库的数据布局人人依据代码本人揣摩吧!
实现规模效益。与传统的用户拥有硬件软件所有权和使用权以及传统的应用服务商提供一对一的服务模式不同,ASP拥有应用系统所有权,用户拥有使用权,应用系统集中放在ASP的数据中心中,集中管理,分散使用,以一对多的租赁的形式为众多用户提供有品质保证的应用技术服务,实现规模效益。 |
|