Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Filtering with ASP

Status
Not open for further replies.

Jovix

Programmer
Dec 3, 2003
39
US
Can anyone tell me how I can sort or filter using asp. The piece of code below pulls a line of data from many e-mail (.eml) documents and writes to one asp page. I need to look at the line the asp pulls from, and only return the files where the line equals 4.

Line = TextStream.readline
If Left(Line,7) = "X-SCL: " then scl=Right(Line,len(Line)-7)
SCL = Left(SCL,1)
If SCL = "" then SCL = "-"
Response.write "<TD><font size=2>" & scl & "</TD>"

Any help will be greatly appreciated.

Jovix
 
what will be the line number??? is it fixed at that position???

Known is handfull, Unknown is worldfull
 
I can think of several methods off the top of my head, but theyw ould all depend on the method your using to loop through the files. Are tere multiple entries in a single file or is each file an individual entity? For example, if Ii find a X-SCL: 4 in a file then do I display the whole file or only part of it?

If your going to return the whole file, do you want it printed to the screen or available as a download link?


My best guess at this point if you want to print the file would be to have a contents variable and do a ReadAll (instead of the readline). Split it on carriage return and loop throught hte resulting array where you are now looping through lines. If you get the 4 then print the contents variable.
If, on the other hand, you just want to create a link, then you should be able to print out a link that points at the filename you just opened right where you are pringint out the number.

In eithe case all you would need is an if statement to check the found number against the target one, then print or not depending on if they match.

-T

[sub]01000111 01101111 01110100 00100000 01000011 01101111 01100110 01100110 01100101 01100101 00111111[/sub]
The never-completed website:
 
Hi guys...

The line is fixed, it will never change. There are no multiple entries in a single file, and that won't change either. The whole piece of code extracts 3 things from each .eml file, the e-mail address, the subject, and this number which is the line my little piece of code is pulling. All the information it collects will write to an asp page formatted like a spreadsheet. So what I'm trying to do is write only the entries or files that contain a number 4.

Just for background, we have a spam filter that catches almost all of our spam, and our filter rates the spam from 1 to 9. If the number is above 4 then the message is spam for sure, but if the message is 4 or below, it could be a legitimate e-mail. So instead of going through thousands of files looking for good e-mail messages, I'm trying to set up this asp page to do it for me.

Thanks for the help guys.
Jovix
 
Please don't forget about me guys...I'm still trying to figure this one out. Hope someone can help
J
 
the "easiest" way i can think of is to create a recordset, pupulate it with your page data,then apply .filter to it or .requery to get the desired results ( and no this does not require a DB or connection )

[thumbsup2]DreX
aKa - Robert
 
hold on,

does this number line come after any other line that holds valuble info that u use? in that case shif the number line to the first line, can u do that?

if not give me an example and ur reading code (from openening the file)...


Known is handfull, Unknown is worldfull
 
Here is the complete code, thanks guys.

<% Option Explicit


Const ForReading = 1, ForWriting = 2, ForAppending = 3
Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0


Dim SCL
Dim xsender
dim xreceiver
dim MsgSubject
dim MsgCount

Sub ListDirectory(objFolder)
Dim objFile
Dim objSubFolder

For Each objFile in objFolder.Files
MsgCount = MsgCount + 1
Response.Write "<TR>"

' Open the file
Dim TextStream
Set TextStream = objfile.OpenAsTextStream(ForReading,TristateUseDefault)
Dim Line


' Read the X-Sender from the first line
Line = TextStream.readline
XSender = "-"
If Left(Line,10) = "x-sender: " then XSender=Right(Line,len(Line)-10)
If XSender = "" then XSender = "-"
Response.write "<TD><font size=2>" & xsender & "</TD>"


' Read the x-receiver from the second line
Line = TextStream.readline
If Left(Line,12) = "x-receiver: " then xreceiver=Right(Line,len(Line)-12)
If Xreceiver = "" then Xreceiver = "-"
Response.write "<TD><font size=2>" & xreceiver & "</TD>"


' Read the x-SCL from the third line
Line = TextStream.readline
If Left(Line,7) = "X-SCL: " then scl=Right(Line,len(Line)-7)
SCL = Left(SCL,1)
If SCL = "" then SCL = "-"
Response.write "<TD><font size=2>" & scl & "</TD>"

Dim SubjectFound

SubjectFound = false
Do While Not TextStream.AtEndOfStream and not SubjectFound
Line = TextStream.readline
If Left(Line,9) = "Subject: " then
SubjectFound = True
MsgSubject = Right(Line,len(Line)-9)
End if
Loop
If MsgSubject = "" then MsgSubject="-"
Response.Write "<TD><font size=2>" & MsgSubject & "</TD>"
Set TextStream = nothing

Response.Write "<TD><font size=2><A HREF=View.asp?Filename=" & ObjFile.Name & ">View</A></TD>"
Response.Write "<TD><font size=2><A HREF=Resubmit.asp?Filename=" & ObjFile.Name & ">Resubmit</A></TD>"
Response.Write "<TD><font size=2><A HREF=DeleteMail.asp?Filename=" & ObjFile.Name & ">Delete</A></TD>"
Response.Write "</TR>"


Next

End Sub



Dim objFSO
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")

%>
<H2 align="center"><font face="Arial" color="#FF0000">Exchange IMF Archive Manager</font></H2>
<BR>
<font face="Arial" size="2">
<A HREF=DeleteAll.asp>Delete all Archived mail</A>

<BR>
<BR>
<TABLE BORDER=2 CELLSPACING=0 CELLPADDING=2 bordercolorlight="#000000" bgcolor="#FFFF99" width="100%" bordercolor="#008000" style="border-collapse: collapse">
<TR>

<TD><font face="Arial" size="2"><B>From</B></TD>
<TD><font face="Arial" size="2"><B>To</B></TD>
<TD><font face="Arial" size="2"><B>SCL</B></TD>
<TD><font face="Arial" size="2"><B>Subject</B></TD>

</TR>


<%

dim ShowRecipient
Dim objFolder
Set objFolder = objFSO.GetFolder(Application("ArchiveDir"))
MsgCount = 0

ListDirectory objFolder

Response.Write ("</TABLE>")
Response.Write ("<P><P>")

Response.Write ("<B>" & MsgCount & " archived messages found</B>")
Response.Write ("<P><P>")
Response.Write ("<A HREF=DeleteAll.asp>Delete all Archived mail</A>")

%>
</font>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top