#141098 - 2005-06-06 11:25 PM
Re: Search the entire exchange server.... all accounts!!
|
masken
MM club member
   
Registered: 2000-11-27
Posts: 1222
Loc: Gothenburg, Sweden
|
|
Top
|
|
|
|
#141102 - 2005-06-07 01:42 AM
Re: Search the entire exchange server.... all accounts!!
|
Bryce
KiX Supporter
   
Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
|
well.. got something ... some what working...
just cant figure out out to get the UDF Openmessage working, it is using the "CDO.Message" to open the email... but i get the following errors.
Quote:
-2147352567 COM exception error "Open" ((null) - The parameter is incorrect. ) [-2147352567/80020009]
I have to have somthing wrong in the OpenMessage function.
you have to run the script on the exchange server, under an account that has access to the mail box in question. the get messages function is working great, it walked the entire inbox folder with no problem.
Code:
break on main
Function Main() GetMessages("file://./BackOfficeStorage/<DOMAIN>/MBX/<USERID>/Inbox/") EndFunction
function GetMessages($szURL) dim $oConn, $oRS $oConn = createobject("ADODB.Connection") $oRS = createobject(ADODB.RecordSet)
Dim $szQuery
;this is a vbscript line crazy quotes?!?!? ;szQuery = "SELECT ""DAV:href"", ""urn:schemas:httpmail:subject"" FROM SCOPE('shallow traversal of """ & szURL & """')"
;kix version?? $szQuery = 'SELECT "DAV:href", "urn:schemas:httpmail:subject" FROM SCOPE(' + "'shallow traversal of " + '"'+ $szURL + '"' +"')" ? $szQuery
$oConn.ConnectionString = $szURL $oConn.Provider = "EXOLEDB.DataSource" $oConn.Open
$oRS.Open($szQuery, $oConn)
While not $oRS.EOF ; Do Something with this item ? $oRS.Fields("urn:schemas:httpmail:subject").Value ;Dump the message Subject ? $oRS.Fields("DAV:href").Value ;Dump the url to the message Item
; Now Open the MEssage OpenMessage($oRS.Fields("DAV:href").Value, $oConn)
$oRS.MoveNext Loop
$oConn = 0 $oRS = 0 Endfunction
;something is wrong with this function, errors. function OpenMessage($szUR, $oConn) debug on dim $oMsg $oMsg = createobject("CDO.Message") ? @error
; Bind to the Message Item $oMsg.DataSource.Open($szURL, $oConn) ? @error " " @serror
; Dump some of the message properties ? $oMsg.Subject " " @error " " @serror ? $oMsg.From" " @error " " @serror ? $oMsg.To" " @error " " @serror $oMsg = 0 Endfunction
|
Top
|
|
|
|
#141103 - 2005-06-07 01:51 AM
Re: Search the entire exchange server.... all accounts!!
|
Lonkero
KiX Master Guru
   
Registered: 2001-06-05
Posts: 22346
Loc: OK
|
|
Top
|
|
|
|
#141106 - 2005-06-07 05:58 AM
Re: Search the entire exchange server.... all accounts!!
|
Bryce
KiX Supporter
   
Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
|
i found a way to get at it with out using "cdo.message" Will post what i foud tomorrow morning when i get back in the office.
Bryce
|
Top
|
|
|
|
#141107 - 2005-06-07 05:20 PM
Re: Search the entire exchange server.... all accounts!!
|
Bryce
KiX Supporter
   
Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
|
This is what i have so far. I can access the text of an email, and search for keywords (simple instr() should do it) in all emails of a given users email folder. You need to run this ecript on the exchange server, and the account that you run it under needs full access to the exchange store.
Now that I can find the emails, i need to figure out what to do with them, i recall seeing some move/copy commands yesterday. perhaps copy the keyword emails to another user folder. something that i could then archive off to a cd and hand to the lawyers to make them happy 
Bryce
Code:
GetMessages("http://<server>/exchange/<user>/inbox")
Function GetMessages($szURL, optional $oconn)
DIM $ors, $szQuery, $count, $url
If VarType($oConn) <> 9 $oConn = CreateObject("ADODB.Connection") EndIf
$oRS = CreateObject(ADODB.RecordSet)
$szQuery = 'SELECT "DAV:href", '+ '"urn:schemas:httpmail:subject",'+ '"urn:schemas:httpmail:datereceived",'+ '"urn:schemas:httpmail:textdescription"'+ ' FROM SCOPE(' + "'shallow traversal of "+'"'+$szURL+'"'+"')"
$oConn.ConnectionString = $szURL $oConn.Provider = "EXOLEDB.DataSource" $oConn.Open
$oRS.Open($szQuery, $oConn)
While not $oRS.EOF
; Do Something with The Data ;? $oRS.Fields("urn:schemas:httpmail:subject").Value ;Dump the message Subject ;? $oRS.Fields("urn:schemas:httpmail:textdescription").value ;? $oRS.Fields("urn:schemas:httpmail:fromemail").value ;? $oRS.Fields("urn:schemas:httpmail:datereceived").value ;? $oRS.Fields("DAV:href").Value ;Dump the url to the message Item
$url = $oRS.Fields("DAV:href").Value If not SubSTR($url,InStrRev($url,".")) ;? $url
;If you want recursive subfolders, uncomment this line. ;GetMessages($url,$oconn) Else ? $url ? $oRS.Fields("urn:schemas:httpmail:textdescription").value EndIf
$oRS.MoveNext Loop
$oConn = 0 $oRS = 0 EndFunction
Bryce
|
Top
|
|
|
|
#141108 - 2005-06-07 06:49 PM
Re: Search the entire exchange server.... all accounts!!
|
Bryce
KiX Supporter
   
Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
|
Alright! i can keep my title of computer guru here at the company! 
here is the move email code! Things are comming toghther
Code:
$1 = "http://<server>/exchange/<userid>/Inbox/testing%20123.EML" $2 = "http://<server>/exchange/<userid>/Inbox/test/testing%20123.EML"
MoveEmail($1,$2)
Function MoveEmail($source, $dest) DIM $record, $cdo, $stream $Record = CreateObject("ADODB.Record") $CDO = CreateObject("CDO.Message") $Record.open($source,,3) $stream = $Record.Fields(-1).Value $cdo.datasource.openobject($stream,"_Stream") $cdo.datasource.saveto($dest) EndFunction
bryce
|
Top
|
|
|
|
#141113 - 2006-04-04 06:23 PM
Re: Search the entire exchange server.... all accounts!!
|
NTDOC
Administrator
   
Registered: 2000-07-28
Posts: 11625
Loc: CA
|
Wow, that's a drag. I would expect 2003 to support that and more - I was hoping it was Exchange 5.5 (which is what we currently have).
Well, I suppose I could try it and see though. That way I can see the error of it not running first hand.
|
Top
|
|
|
|
#141115 - 2006-04-04 07:17 PM
Re: Search the entire exchange server.... all accounts!!
|
NTDOC
Administrator
   
Registered: 2000-07-28
Posts: 11625
Loc: CA
|
arghh... did not work. Forced a bad path on purpose and it still comes back saying no error.
|
Top
|
|
|
|
#141116 - 2006-04-05 07:06 AM
Re: Search the entire exchange server.... all accounts!!
|
NTDOC
Administrator
   
Registered: 2000-07-28
Posts: 11625
Loc: CA
|
Well after a bit of searching I was able to find the MSS file for Message Store Sanitizer that supposedly can do this as well.
Quote:
Message Store Sanitizer Version 1.1 Microsoft Premier Support 30 March 1999
Release Notes
What is it? =========== Message Store Sanitizer is a utility that allows an Exchange Server store to be searched for a particular occurrence of a message and optionally delete it. It has been used with success to remove the "Melissa" virus using a search based on a string in the subject line. Versions are available for both i386 and Alpha platforms.
How does it work? ================= MSS utilizes standard MAPI calls to enumerate the mailboxes within a designated Exchange container (it will traverse subcontainers by specifying the top-level container), then compare each message in those mailboxes against user-defined criteria. Two modes of operation are available:
Report - Messages that match the criteria are logged to a file, but no deletions occur. Delete - Messages that match the criteria are logged to a file, and are permanently deleted from the store.
The utility can be set to run in an unattended mode using the Windows NT AT scheduler service.
Parameters are designated in an .ini file (usually named mss.ini).
Message Store Sanitizer and related files. ftp://ftp.microsoft.com/Services/TechNet/Seminars/19990323Troubleshoot_Part_1/Melissa/
|
Top
|
|
|
|
Moderator: Arend_, Allen, Jochen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 1574 anonymous users online.
|
|
|