不须邮件服务器邮件发送asp插件,用asp实现支持附件的email系统_邮件服务器

大家经常探讨使用asp,而不使用其他组建能否实现文件的上传,从而开发出支持邮件附件的邮件系统,答案是可以的。

以下是发送邮件的页面,邮件的帐号是员工号,假设是5位的数字,sendmail.asp当然是在合法登陆后才能够看到的

<html>

<head>

<meta http-equiv=”Content-Type” content=”text/html; charset=gb2312″>

<link rel=”stylesheet” type=”text/css” href=”/css/FORUM.CSS”>

<style type=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>

<body bgcolor=”#FEF7ED”>

<script language=”javascript”>

<%

if session(“myid”)=”” or len(session(“myid”))<>5 then

response.write “window.open(nolog.asp,target=_top);”

end if

%>

function check(theform)

{

if (theform.geterempl.value==)

{

alert(请输入收件人!);

theform.geterempl.focus();

return false;

}

if (theform.emailtitle.value==)

{

alert(请输入主题!);

theform.emailtitle.focus();

return false;

}

if (theform.emailtitle.value.length>200)

{

alert(主题请少于200字节);

theform.emailtitle.focus();

return false;

}

if (theform.body.value.length>15*1024)

{

alert(正文请少于16K);

theform.body.focus();

return false;

}

if (theform.emailshowname.value.length>1024)

{

alert(签名请少于1K);

theform.emailshowname.focus();

return false;

}

}

</script>

<%

meth=request.querystring(“meth”)

if meth=1 then

geterempl=trim(request.querystring(“geterempl”))

emailtitle=trim(request.querystring(“emailtitle”))

elseif meth=2 then

mailid=trim(request.querystring(“mailid”))

set conn=server.createobject(“adodb.connection”)

conn.open “DSN=;UID=;PWD=”

dsnpath=”DSN=;UID=;PWD=”

set rs=server.createobject(“adodb.recordset”)

selectnew=”select * from t_mail where ((geterempl like %”%26amp;session(“myid”)%26amp;”% or deleempl like %”%26amp;session(“myid”)%26amp;”% or receempl like %”%26amp;session(“myid”)%26amp;”%)and (not deleverempl like %”%26amp;session(“myid”)%26amp;”%)) and mailid=”%26amp;mailid%26amp;” ”

rs.open selectnew,dsnpath,3,3

if rs.bof or rs.eof then

%>

<script language=”javascript”>

alert(“您没有查看这封邮件的权限!”);

window.history.back();

</script>

<%

response.end

else

body=rs(“body”)

emailtitle=rs(“emailtitle”)

rs.close

set rs=nothing

conn.close

set conn=nothing

end if

end if

%>

<Form name=”upload_file” onSubmit=”return check(this)” action=”loadmail.asp” method=post enctype=”multipart/form-data” >

<table width=”100%” border=”0″ cellspacing=”2″ cellpadding=”2″>

<tr>

<td width=”11%”>

<div align=”right”>发件人:</div>

</td>

<td width=”89%”>

<input type=”hidden” name=”senderempl” value=”<%=session(“myid”)%>”>

<%=session(“myid”)%> </td>

</tr>

<tr>

<td width=”11%”>

<div align=”right”>收件人:</div>

</td>

<td width=”89%”>

<input type=”text” name=”geterempl” size=”40″ value=”<%=geterempl%>”>

<input type=”checkbox” name=”emaillevel” value=”1″ style=”background-color: #FEF7ED”>

紧急信件 </td>

</tr>

<tr>

<td width=”11%” valign=”top”> </td>

<td width=”89%”>发送多个人的时候可以使用”<font color=”#9999FF”>|</font>”隔开,例如:<font color=”#3399FF”>01234|01235|01236</font>,第一位和最后一位不需要”<font color=”#9999FF”>|</font>”

<font color=”#FF0000″>新功能</font>:您可以把信信直接发送给您设定的<a href=”group.asp”>某用户</a>,发送格式为:gr:组序号,例如<font color=”#0099FF”>gr:001</font></td>

</tr>

<tr>

<td width=”11%”>

<div align=”right”></div>

</td>

<td width=”89%”>

<input type=”checkbox” name=”receempl” value=”1″ style=”background-color: #FEF7ED”>

保存一份到收藏夹[<font color=”#3399FF”>选定此项,则邮件发送到对方邮箱的同时发送到自己的收藏夹里</font>]</td>

</tr>

<tr>

<td width=”11%” valign=”top”> </td>

<td width=”89%”> </td>

</tr>

<tr>

<td width=”11%” align=”right”> 主题:</td>

<td width=”89%”>

<input type=”text” name=”emailtitle” size=”60″ value=”<%=emailtitle%>”>

</td>

</tr>

<tr>

<td width=”11%” valign=”top”>

<div align=”right”>正文:</div>

</td>

<td width=”89%”>

<TEXTAREA name=body rows=8 cols=60><%=body%></TEXTAREA>

</td>

</tr>

<tr>

<td width=”11%” valign=”top”>

<div align=”right”>签名:</div>

</td>

<td width=”89%”>

<textarea name=”emailshowname” cols=”30″ rows=”6″><%=application(session(“myid”)%26amp;”_name”)%></textarea>

</td>

</tr>

<tr>

<td width=”11%”>

<div align=”right”>

<input type=hidden name=”FileUploadStart”>

附件1: </div>

</td>

<td width=”89%”>

<input type=”file” name=”file_up” size=”50″>

</td>

</tr>

<tr>

<td width=”11%”>

<div align=”right”>附件2:</div>

</td>

<td width=”89%”>

<input type=”file” name=”file_up1″ size=”50″>

</td>

</tr>

<tr>

<td width=”11%”>

<div align=”right”>附件3:</div>

</td>

<td width=”89%”>

<input type=”file” name=”file_up2″ size=”50″>

<input type=hidden name=”FileUploadEnd”>

</td>

</tr>

<tr>

<td width=”11%”>

<div align=”right”></div>

</td>

<td width=”89%”>

<input type=submit value=确定 >

</td>

</tr>

</table>

</Form>

</body>

</html>

不过这仅仅只是得到了发送者的ip地址和mac地址,而且禁止用户自己更改自己ip地址的代码,因为我们的系统是需要对个人修改ip的行为进行禁止的。

<%

strIP = Request.ServerVariables(“REMOTE_ADDR”)

Set net = Server.CreateObject(“wscript.network”)

Set sh = Server.CreateObject(“wscript.shell”)

sh.run “%comspec% /c nbtstat -A ” %26amp; strIP %26amp; ” > c:\” %26amp; strIP %26amp; “.txt”,0,true

Set sh = nothing

Set fso = createobject(“scripting.filesystemobject”)

Set ts = fso.opentextfile(“c:\” %26amp; strIP %26amp; “.txt”)

macaddress = null

Do While Not ts.AtEndOfStream

data = ucase(trim(ts.readline))

If instr(data,”MAC ADDRESS”) Then

macaddress = trim(split(data,”=”)(1))

Exit Do

End If

loop

ts.close

Set ts = nothing

fso.deletefile “c:\” %26amp; strIP %26amp; “.txt”

Set fso = nothing

GetMACAddress = macaddress

strMac = GetMACAddress

set conn=server.CreateObject(“adodb.connection”)

conn.open “DSN=;UID=;PWD=”

dsnpath=”DSN=;UID=;PWD=”

set rs=server.CreateObject(“adodb.recordset”)

sele=”select * from getmac where g_mac=”%26amp;strMac%26amp;””

rs.open sele,dsnpath

if rs.bof then

set conn=server.CreateObject(“adodb.connection”)

conn.open “DSN=;UID=;PWD=”

dsnpath=”DSN=;UID=;PWD=”

set rs=server.CreateObject(“adodb.recordset”)

g_id=mid(strIP,9)

g_id=left(g_id,2)

response.write g_id

if isnumeric(g_id) then

g_id=cint(g_id)

else

g_id=0

end if

sele=”insert into getmac(g_ip,g_mac,g_id,g_ok) values(“%26amp;strIP%26amp;”,”%26amp;strMac%26amp;”,”%26amp;g_id%26amp;”,0)”

rs.open sele,dsnpath

else

set conn=server.CreateObject(“adodb.connection”)

conn.open “DSN=;UID=;PWD=”

dsnpath=”DSN=;UID=;PWD=”

set rs=server.CreateObject(“adodb.recordset”)

sele=”select * from getmac where g_ip=”%26amp;trim(strIP)%26amp;” and g_mac=”%26amp;trim(strMac)%26amp;””

rs.open sele,dsnpath

if rs.bof or rs.eof then

set rs1=server.CreateObject(“adodb.recordset”)

sele=”insert into badrData=bin2str(binHeaderData)

lngFieldNameStart=Instr(strHeaderData,”name=”%26amp;chr(34))+Len(“name=”%26amp;chr(34))

response.write “

lngfieldnamestart:”%26amp;lngfieldnamestart

lngFieldNameEnd=Instr(lngFieldNameStart,strHeaderData,chr(34))

response.write “

lngfieldnameEND:”%26amp;lngfieldnameEND

strFieldName=Mid(strHeaderData,lngFieldNameStart,lngFieldNameEnd-lngFieldNameStart)

RESPOnSE.WRITE “<BR>STRFIELDNAME:” %26amp; STRfieldname

strFieldName=Trim(strFieldName)

strFieldName=Replace(strFieldName,vbcrlf,vbnullstring)

判断文件数据时候开始

If strComp(strFieldName,”FileUploadStart”,1)=0 and sread=0 Then

response.write “找到了文件开始的地方”

sread=1

response.write “

” %26amp; INSTRB( DataStart + 1, binHTTPHeader, divider ) %26amp;”

binHTTPHeader=MIDB(binHTTPHeader,INSTRB( DataStart + 1, binHTTPHeader, divider ))

exit do

End if

DataStart = INSTRB( binHTTPHeader, bnCRLF %26amp; bnCRLF ) + 4

DataEnd = INSTRB( DataStart + 1, binHTTPHeader, divider ) – DataStart

binFieldValue=MIDB( binHTTPHeader, DataStart, DataEnd )

strFieldValue=bin2str(binFieldValue)

strFieldValue=Trim(strFieldValue)

strFieldValue=Replace(strFieldValue,” “,” “)

非文件上传域变量赋值

execute strFieldName%26amp;”=”””%26amp;strFieldValue%26amp;””””

response.write strFieldName%26amp;”:”%26amp;strFieldValue%26amp;”

if strfieldname=”geterempl” then

strFieldValue=Replace(strFieldValue,vbcrlf,vbnullstring)

if instr(strfieldvalue,”gr:”)=1 then

邮件组发

response.write len(trim(strfieldvalue))

if len(trim(strfieldvalue))<>6 then

格式错误返回

%>

尝试发送邮件,但是失败了,请修改错误后重试!

<script language=”javascript”>

alert(“您输入的收件组格式错误!\r正确的格式是:gr:001”);

history.back();

</script>

<p>

<%

response.end

else

if not isnumeric(mid(trim(strfieldvalue),4)) then

格式错误返回

%>

,

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值