⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 recipt.asp

📁 功能齐全的oa系统
💻 ASP
字号:
<!--#include virtual ="/Include/DataEnvi.asp"-->
<!--#include virtual ="/Include/function.asp"-->

<%
'Response.End 
	Path	=	Server.MapPath("../../OA/Attach/Files/Mail")
	Name	=	""
	If	Not IsExistFold(Path,Name) Then
		UserFold	=	CreateFold(Path,Name)
	Else
		UserFold	=	"../../OA/Attach/Files/Mail/" & Name
		UserFold	=	Server.MapPath(UserFold)
	End If
'Response.End 
%>
<%
Dim StrErrMsg,StrErrDes
Dim ObjPop3,IntMessageCount
Dim AccountID,FromName,FromAddr,ContentType,Priority,Subject,Body,IsAttach,BoxID,BoxIDBak,IsValid,SendTime,CreateTime
Dim MessageID,FileName,FileSize,ExtName,BasePath,Path,Name,myValue,Fold
AccountID	=	session("AccountID")
Dim objDB,objRS,strSQL,objRSAttach
Set objDB	=	server.CreateObject("ADODB.Connection")
OpenDB	objDB
Set objRS	=	server.CreateObject("ADODB.Recordset")
Set objRSAttach	=	server.CreateObject("ADODB.Recordset")
strSQL = "select * from t_OA_Message Where ID=0"
objRS.Open strSQL,objDB,1,3
strSQL = "select * from t_OA_Attach Where ID=0"
objRSAttach.Open strSQL,objDB,1,3

On Error resume next

Set ObjPop3		= Server.CreateObject("JMail.POP3")
Set Messages	= Server.CreateObject("JMail.Messages")
Set Message		= Server.CreateObject("JMail.Message")
Set Attachments	= Server.CreateObject("JMail.Attachments")
Set Attachment	= Server.CreateObject("JMail.Attachment")

Dim	objRSAccountID,userName,password,ServerAddr
Set objRSAccountID	=	server.CreateObject("ADODB.Recordset")
strSQL	=	"select a.userName,a.password,b.address,b.Ip from t_OA_Message_Account a,t_OA_Message_MailServer b where a.AccountID=" & AccountID &" And a.MailServerID=b.ID"
'Response.Write strSQL
objRSAccountID.Open strSQL,objDB,1,3

DO WHILE NOT objRSAccountID.EOF 
	userName	=	objRSAccountID.Fields("userName") & "@" & objRSAccountID.Fields("address")
	password	=	objRSAccountID.Fields("password")
	ServerAddr	=	"http://" & objRSAccountID.Fields("Ip")
	'Response.End 

  ObjPop3.Connect userName,password,ServerAddr
	
If Err.number <> 0 Then
	StrErrDes = Err.description
	If InStr(1,StrErrDes,"invalid username") Then
		StrErrMsg = "用户名错误:" & userName
	ElseIf InStr(1,StrErrDes,"wrong password") Then
		StrErrMsg = "密码错误  用户名:" &  userName
	Else
		StrErrMsg = ""
	End If
End If
If StrErrMsg <> "" Then
	Response.Write StrErrMsg
	'Response.End 
End If

Set Messages = ObjPop3.Messages
'ObjPop3.DownloadHeaders
IntMessageCount = Messages.Count 

For i =  1 To IntMessageCount-1
	Set Message = Messages.Item(i)
	objRS.AddNew()
	objRS.Fields("AccountID")		=	AccountID
	objRS.Fields("FromName")		=	Message.FromName 
	objRS.Fields("FromAddr")		=	Message.From 
	objRS.Fields("ContentType")	=	Message.ContentType 
	objRS.Fields("Priority")		=	Message.Priority
	objRS.Fields("Subject")			=	Message.Subject	
	objRS.Fields("Body")			  =	Message.Body
	objRS.Fields("BoxID")			  =	1
	objRS.Fields("BoxIDBak")		=	1
	objRS.Fields("IsValid")			=	1
	objRS.Fields("SendTime")		=	Message.Date 
	objRS.Fields("CreateTime")	=	Now()
	
	Set Attachments = Message.Attachments
	IntAttCount	=	0
	IntAttCount = Attachments.Count
	 
	If IntAttCount > 0 Then
		objRS.Fields("IsAttach")	=	1
	End If

	
	MessageID	=	objrs.Fields("ID")
	For j = 0 To IntAttCount-1
		Set Attachment = Attachments.Item(j)

		Randomize
		KeyPath	=	Year(Date()) & Month(Date()) & Day(Date())
		KeyPath	=	KeyPath & Hour(Time()) & Minute(Time()) & Second(Time())
		KeyPath	=	KeyPath & (20000-Cint(10000*Rnd))
		Fold	=	CreateFold(UserFold,KeyPath)	

		Attachment.SaveToFile(Fold & "\" & Attachment.Name)
		objRSAttach.AddNew()
		objRSAttach.Fields("FileName")	=	Attachment.Name
		objRSAttach.Fields("FileSize")	=	attachment.Size
		objRSAttach.Fields("BasePath")		=	"Mail"
		objRSAttach.Fields("KeyPath")		=	KeyPath
		objRSAttach.Fields("AccountID")		=	Session("AccountID")
		objRSAttach.Update()
		
		StrKeyPath = StrKeyPath & KeyPath & ","
	Next
	If StrKeyPath<>"" Then StrKeyPath = Left(StrKeyPath,Len(StrKeyPath)-1)

	ObjRS.Fields("Attachs") = StrKeyPath
	objrs.Update()	

Next

objRSAccountID.MoveNext()
LOOP

ObjPop3.DeleteMessages()

if IntMessageCount <> 0 then 
  IntMessageCount = IntMessageCount-1
else
  IntMessageCount = 0
end if

StrMSG = "共接收到<font color=red>" & IntMessageCount & "</font>封新邮件"

Function getExtName(File)
	Int Pos1 
	Pos1		=	InstrRev(File,".") + 1
	getExtName	=	Mid(File,Pos1)
End Function

%>
<script>
top.doAlert(1,"<%=StrMSG%>")
var R = Math.random();
parent.navigate('List.asp?ID=1&R='+R)
parent.parent.frmToolbar.doList(1);
</script>

	

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -