BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 07-23-2007, 06:13 PM   #1 (permalink)
Thumbs Must Hurt
 
Join Date: Jul 2007
Location: city11 -inspectral
Model: 8100
PIN: N/A
Carrier: Cingular
Posts: 79
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Request for testers: BES Exchange Ref ID / Folder ID script

Please Login to Remove!

Last week we ran into a situation at work where we needed to translate the Ref IDs and Folder IDs in the BES logs into the actual items in a user's mailbox. I couldn't find a way to do this, and our contact at RIM didn't know of a way either, other than poking around in the mailbox with MFCMAPI or OutlookSpy.
That's a really slow way of searching for a known ID, so I decided to write a script that would scan through a mailbox and dump some relevant information about each item as tab-delimited text. Specifically, the To/From, Subject, Sent/Received information about the items as well as the Ref ID and Folder ID tags that the BES applies. Once the data is dumped, it can be opened in e.g. Excel so that the Ref ID or Folder ID can be searched on.
This was made a little more complicated because RIM tags their custom fields using ANSI strings instead of Unicode like they're supposed to (maybe Exchange 5.5 uses ANSI? We only have 2003), but I was able to teach VBScript how to cast an ANSI string as Unicode.
Anyway, now that I think I have it working, I thought I would post it here in case anyone else would like to try it out. I would appreciate comments, and if it doesn't work for someone, it would be helpful to know which version of the BES and Exchange they are running, and on what OS(es).
The usage is from the command line, and is in the form:
cscript -nologo DumpMailboxItemData.vbs SERVER MAILBOX > Output.txt
Where SERVER is the user's Exchange server and MAILBOX is the name of the user's mailbox.
Obviously it needs to be run in the context of an account with at least read access to the target mailbox (e.g. BESAdmin).
Once the script finishes, the output text file can be opened in e.g. Excel and the Ref or Folder ID from the logs searched on.
I tested this on a 600MB mailbox being read over a WAN link and it took about half an hour. Running it locally on the Exchange server where the actual mailbox resides should be pretty speedy.
Some notes:
- Only messages created after activation are tagged with the Folder and Ref ID data.
- If a message is tagged, then the userxxx8217;s handheld is wiped and Enterprise Activated again, the previous messages will still be tagged, but those tags will not be updated by the BES. This can lead to inconsistencies in the field information for older items, particularly when trying to figure out which folder is mapped to by a particular Folder ID.
- Only email is tagged, not calendar appointments or contacts.
- Messages moved to the Deleted Items folder in Outlook do not have their Folder ID tag updated. This can be useful in determining which folder they were deleted from.
- The script can be customized to grab other fields, and/or not apply the ANSI -> Unicode cast if necessary.
Code:
Note: code removed, see updated version later in thread.
__________________
Legacy of Kain: The Lost Worlds
http://www.thelostworlds.net/

Last edited by blincoln : 11-14-2007 at 05:36 PM. Reason: Removed old code
Offline  
Old 07-26-2007, 10:10 AM   #2 (permalink)
Thumbs Must Hurt
 
Join Date: Dec 2005
Location: Toronto
Model: 7290
Carrier: Rogers
Posts: 57
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello

very interesting script. The only problem i have when mailbox name is in the form of lastname, firstname. There is comma and space between them. I tried to use "lastname, firstname" but your script does not like that.

Any hints on how to supply mailbox with spaces in it?

thanks
Offline  
Old 07-26-2007, 11:35 AM   #3 (permalink)
Thumbs Must Hurt
 
Join Date: Jul 2007
Location: city11 -inspectral
Model: 8100
PIN: N/A
Carrier: Cingular
Posts: 79
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi RipThorn. Did you put the "lastname, firstname" in quotation marks? I just tried that from the command line like this:
cscript -nologo DumpMailboxItemData.vbs someserver "lincoln, ben"
...and it worked correctly.
If that doesn't work for you, what error are you getting? Also, as a workaround, you should be able to use the SAM account name for the account associated with the mailbox if you use those on your domain.
__________________
Legacy of Kain: The Lost Worlds
http://www.thelostworlds.net/
Offline  
Old 07-26-2007, 02:19 PM   #4 (permalink)
Thumbs Must Hurt
 
Join Date: Dec 2005
Location: Toronto
Model: 7290
Carrier: Rogers
Posts: 57
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default My mistake

I fixed it. It was permission issues rather than mailbox name. I was using exchange admin account to do that. Once i switched to bes admin account your script works perfectly.

After running it i have more question

I don;t see any calendar entries. I have a user that keeps getting calendar reminders but when you try to open it just gives you 'Appointment deleted externally. Changes will be lost and the viewer closed'.

And when you go to Outlook there is no calendar entries.

I was hoping that somehow i could trace calendar ref's and match them in user's Outlook calendar items

thank you
Offline  
Old 07-26-2007, 02:41 PM   #5 (permalink)
Thumbs Must Hurt
 
Join Date: Jul 2007
Location: city11 -inspectral
Model: 8100
PIN: N/A
Carrier: Cingular
Posts: 79
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Cool! I'm glad it works.
If you put a single quote in front of this line:
gObjFolderExcludeHash.Add "Calendar", "Calendar"
(so it looks like this)
'gObjFolderExcludeHash.Add "Calendar", "Calendar"
It will remove the calendar from the exclusions list, and then when you run the script those items will be in the output.
I excluded it when running it myself because at least with the way our BES systems are configured, we don't get log entries for calendar appointments that include Ref IDs, and I didn't see anything that looked like a custom RIM field in the appointments like there are in the regular messages.
Do you know what the log level is set to on your BES? I might be able to tweak ours and figure out what the BES is using to track calendar appointments, which would help answer your question.
__________________
Legacy of Kain: The Lost Worlds
http://www.thelostworlds.net/
Offline  
Old 07-27-2007, 07:58 AM   #6 (permalink)
Kul
Talking BlackBerry Encyclopedia
 
Kul's Avatar
 
Join Date: May 2005
Location: London, England.
Model: 9300
Carrier: Vodafone (UK)
Posts: 442
Post Thanks: 19
Thanked 2 Times in 2 Posts
Default

I was trying this and keep getting the follwing error when running the script.

the syntax used is:
cscript -nologo DumpMailboxItemData.vbs servername "firstname lastname"

the error i get is:
DumpMailboxItemData.vbs (1,7) MS VBScript compilation error: syntax error

I am also using the account which has all the required permissions

any ideas
Offline  
Old 07-27-2007, 08:34 AM   #7 (permalink)
Kul
Talking BlackBerry Encyclopedia
 
Kul's Avatar
 
Join Date: May 2005
Location: London, England.
Model: 9300
Carrier: Vodafone (UK)
Posts: 442
Post Thanks: 19
Thanked 2 Times in 2 Posts
Default

got it to work, had accidently entered a character in the script
Offline  
Old 07-27-2007, 10:05 AM   #8 (permalink)
Thumbs Must Hurt
 
Join Date: Dec 2005
Location: Toronto
Model: 7290
Carrier: Rogers
Posts: 57
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

All of my logs including MAGT are set to 4. should i bump it to 5 maybe?

Anywho. User got this reminder again for July 27, 2007 9:00 am July 27, 2007 9:30am.

Trying to click to open - appointment appears with no subject line or location, shows as none (for reocurrence)

I've run your script this time i enabled Calendar but can;t seem to find anything at 9:00am

this is driving me nuts

I don;t see any ref id for those calendar entries

below is your script in action

Folder Sender Recipient Subject Sent Received PR_RIM_MSG_REF_ID PR_RIM_MSG_FOLDER_ID
\Calendar Mah, Tina [NULL] Telecon HR [NULL] [NULL] [NULL] [NULL]
\Calendar Mah, Tina [NULL] Balance of care data submission [NULL] [NULL] [NULL] [NULL]
\Calendar Mah, Tina [NULL] Lissa [NULL] [NULL] [NULL] [NULL]
\Calendar Mah, Tina [NULL] Glenn on call [NULL] [NULL] [NULL] [NULL]
\Calendar Mah, Tina [NULL] Hair cut [NULL] [NULL] [NULL] [NULL]
\Calendar Mah, Tina [NULL] Dentist [NULL] [NULL] [NULL] [NULL]
\Calendar Mah, Tina [NULL] Dentist [NULL] [NULL] [NULL] [NULL]
\Calendar Mah, Tina [NULL] Vacation [NULL] [NULL] [NULL] [NULL]
\Calendar Mah, Tina [NULL] Helen [NULL] [NULL] [NULL] [NULL]

\Calendar Mah, Tina [NULL] Inta on-call 7/20/2007 14:47 7/20/2007 14:47 [NULL] [NULL]
\Calendar Mah, Tina [NULL] Tina on-call 7/20/2007 14:48 7/20/2007 14:48 [NULL] [NULL]
\Calendar Mah, Tina [NULL] Kim on-call 7/20/2007 14:49 7/20/2007 14:49 [NULL] [NULL]
\Calendar Mah, Tina [NULL] Glenn on-call 7/20/2007 14:49 7/20/2007 14:49 [NULL] [NULL]
\Calendar Mah, Tina [NULL] Brent on-call 7/20/2007 14:49 7/20/2007 14:49 [NULL] [NULL]
\Calendar Poll, Chris [NULL] Canceled: Operational Planning - Latest Version 7/23/2007 8:52 7/23/2007 8:52 [NULL] [NULL]
\Calendar Gra, Claire [NULL] Follow up to meeting with WWLHIN re. ALC's 7/23/2007 13:34 7/23/2007 13:34 [NULL] [NULL]
\Calendar Gra, Claire [NULL] LHINvitation - "Champions of Change" Symposium 7/23/2007 13:48 7/23/2007 13:48 [NULL] [NULL]
\Calendar Gra, Claire [NULL] Annual Report & APs 7/23/2007 15:43 7/23/2007 15:43 [NULL] [NULL]
\Calendar Be, Dawn [NULL] Canceled: Corporate Score Card Refresh Project 7/24/2007 15:29 7/24/2007 15:29 [NULL] [NULL]
\Calendar Mah, Tina [NULL] Board meeting 7/24/2007 16:29 7/24/2007 16:29 [NULL] [NULL]
\Calendar Mah, Tina [NULL] Meeting re. the P Drive 7/25/2007 0:20 7/25/2007 0:20 [NULL] [NULL]
\Calendar Mah, Tina [NULL] Research Day 7/25/2007 0:22 7/25/2007 0:22 [NULL] [NULL]
\Calendar Mah, Tina [NULL] Meeting Toronto 7/26/2007 13:52 7/26/2007 13:52 [NULL] [NULL]
\Calendar Mah, Tina [NULL] no meetings 7/26/2007 16:39 7/26/2007 16:39 [NULL] [NULL]
Offline  
Old 07-30-2007, 06:21 PM   #9 (permalink)
Thumbs Must Hurt
 
Join Date: Jul 2007
Location: city11 -inspectral
Model: 8100
PIN: N/A
Carrier: Cingular
Posts: 79
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

If the 9:00AM appointment is a recurring one, it might not show up in the output in the place you expect it to. Is there anything suspicious if you look by the subject line?

If you are comfortable using its interface, MFCMAPI might let you find and delete the problem appointment too.

Also, the reason I was asking about your log levels is I thought you were seeing Ref IDs for calendar appointments in your BES logs. Maybe I misunderstood? I don't see anything in our logs for appointments other than a notification that a sync happened.
__________________
Legacy of Kain: The Lost Worlds
http://www.thelostworlds.net/
Offline  
Old 07-31-2007, 04:48 AM   #10 (permalink)
Knows Where the Search Button Is
 
Join Date: Jun 2006
Model: 8800v
Carrier: Vodafone
Posts: 38
Post Thanks: 0
Thanked 0 Times in 0 Posts
Thumbs up

Hey - sweet script! This will be very useful thanks We use Exchange 5.5, so I had to use the mailbox alias as opposed to the display name in order for MAPI to log on.

Adam.

EDIT: Same NULLness problem with calendar appts/mtgs as RipThorn ^^^

Last edited by ACJones : 07-31-2007 at 05:17 AM.
Offline  
Old 07-31-2007, 09:44 AM   #11 (permalink)
Thumbs Must Hurt
 
Join Date: Dec 2005
Location: Toronto
Model: 7290
Carrier: Rogers
Posts: 57
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

There is not subject or body or location details. nothing
When you open it it just says Appointment delete externally. Viewer will now close. Very weird

I created a separate entry for this problem.
Offline  
Old 08-08-2007, 07:49 PM   #12 (permalink)
Thumbs Must Hurt
 
Join Date: Jul 2007
Location: city11 -inspectral
Model: 8100
PIN: N/A
Carrier: Cingular
Posts: 79
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Here is an updated version of the script that also tries to find a RefID for calendar items. This is hot off the presses (and the way the BES stores the calendar RefIDs is fairly complicated), so I would definitely appreciate hearing from people regarding whether it works or not.

There is a separate column for the calendar RefIDs because they're obtained in a different way.

Code:
Deleted, see updated version in next post.
__________________
Legacy of Kain: The Lost Worlds
http://www.thelostworlds.net/

Last edited by blincoln : 08-09-2007 at 02:22 PM. Reason: Remove obsolete code
Offline  
Old 08-09-2007, 02:24 PM   #13 (permalink)
Thumbs Must Hurt
 
Join Date: Jul 2007
Location: city11 -inspectral
Model: 8100
PIN: N/A
Carrier: Cingular
Posts: 79
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

I found a better way to get the reference to the BlackBerry calendar data. Here is an updated version of the script that should also run a bit faster as well as catching more of the appointments' RefIDs:

Code:
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'                            DumpMailboxItemData.vbs                             '
'                                  Version 1.2                                   '
'                                                                                '
' Outputs tab-delimited text based on information in a user's Exchange mailbox   '
' Intended for use with user accounts which are also set up on a Blackberry      '
' Enterprise Server.                                                             '
'                                                                                '
'                                                                                '
'                            Ben Lincoln, 2007-08-09                             '
'                         http://www.thelostworlds.net/                          '
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Option Explicit

' Custom field names to read from the mailbox items.
' Two arrays are necessary in order to keep one human-readable
Dim gArrFieldsToRead, gArrFieldsToReadNames

' A hashtable of top-level folder names that should not be processed
Dim gObjFolderExcludeHash
Set gObjFolderExcludeHash = CreateObject("Scripting.Dictionary")

' Name of the root-level BlackBerry information folder in the user's mailbox
Const gStrBlackBerryRootFolder = "BlackBerryHandheldInfo"

' Name of the BlackBerry subfolder which contains the calendar sync data
Const gStrBlackBerryCalSyncFolder = "BlackBerryCalSyncState"

' Hex codes for the fields in the BlackBerry calendar sync items 
' Calendar item message ID
Const gIntBBCalSyncCalID = &H62050102
' BlackBerry Ref ID copy 1
Const gIntBBCalSyncRefID1 = &H62030003
' BlackBerry Ref ID copy 2
Const gIntBBCalSyncRefID2 = &H62040003

' Hex codes for the fields in the Exchange calendar items
' The field number of PR_CHANGE_KEY
Const gIntChangeKeyFieldNumber = &H65E20102


''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''' Begin script customization options '''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''


' Add or remove entries in this array to alter the collection of data from custom fields
' Example: "PR_RIM_MSG_REF_ID"
gArrFieldsToRead = Array("PR_RIM_MSG_REF_ID", "PR_RIM_MSG_FOLDER_ID")

' As of BES 4.1.2, RIM is incorrectly using ANSI field names rather than Unicode
' on systems that support Unicode.
' If they mend their ways, change this constant to be False rather than True.
Const gCastFieldNamesANSIToUnicode = True

' Add or remove .Add lines below to exclude top-level folders from processing by name
' Example: gObjFolderExcludeHash.Add "Calendar", "Calendar"
' gObjFolderExcludeHash.Add "Calendar", "Calendar"
gObjFolderExcludeHash.Add "Contacts", "Contacts"


''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''           End script customization options           ''''''''''''''
'''''''''''''' Do not modify below this line for normal maintenance ''''''''''''''
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

' Get arguments from command line
If WScript.Arguments.Count <> 2 Then
	WScript.Echo "Missing one or more arguments."
	WScript.Echo "Usage: cscript -nologo DumpMailboxItemData.vbs28 [SERVER] [MAILBOX]"
	WScript.Echo "Example: cscript -nologo DumpMailboxItemData.vbs mailserver01 blincoln"
	WScript.Quit 1
End If

Main WScript.Arguments(0), WScript.Arguments(1)


'''''''''''

Function Main(strExchangeServer, strMailboxName)

	Dim intFieldNum

	gArrFieldsToReadNames = gArrFieldsToRead
	' If necessary, cast ANSI field names to Unicode
	If gCastFieldNamesANSIToUnicode = True Then
		For intFieldNum = 0 To UBound(gArrFieldsToRead)
			gArrFieldsToRead(intFieldNum) = CastANSIStringToUnicodeString(gArrFieldsToRead(intFieldNum))
		Next
	End If

	Dim strProfileInfo
	Dim objMAPISession

	Dim objInfoStore	
	Dim objFolders
	Dim objFolder
	Dim objMapHash

	strProfileInfo = strExchangeServer & vbLf & strMailboxName
	Set objMAPISession = CreateObject("mapi.session")
	objMAPISession.Logon "", "", False, True, 0, True, strProfileInfo
	
	Set objInfoStore = objMAPISession.InfoStores.Item(2)
	Set objFolders = objInfoStore.Rootfolder.Folders

	On Error Resume Next
	Set objMapHash = GetBlackBerryMappings(objMAPISession)
	If Err.Number <> 0 Then
		Set objMapHash = CreateObject("Scripting.Dictionary")
		WScript.Echo "WARNING: Unable to obtain the BlackBerry Calendar sync data for this mailbox."
		Err.Clear
	End If
	On Error GoTo 0

	' Used to keep track of where the script is when processing folder names for display
	Dim strGlobalFolder
	strGlobalFolder = ""

	' Column headers
	Dim strHeaders
	strHeaders = "Folder" & vbTab & "Sender" & vbTab & "Recipient" & vbTab & _
		"Subject" & vbTab & "Sent" & vbTab & "Received" & vbTab & "Calendar RefID(s)" & vbTab
	For intFieldNum = 0 To UBound(gArrFieldsToReadNames)
		strHeaders = strHeaders  & gArrFieldsToReadNames(intFieldNum) & vbTab
	Next
	WScript.Echo strHeaders

	For Each objFolder In objFolders
		If Not gObjFolderExcludeHash.Exists(objFolder.Name) Then
			ProcessFolder objFolder, strGlobalFolder, objMapHash
		End If
	Next

	objMAPISession.Logoff

End Function

Function GetBlackBerryMappings(objMAPISession)
	Dim objRoot
	Dim objBBRootFolder
	Dim objBBCalSyncFolder
	Dim objMapHash
	Dim objMessages
	Dim objMessage
	Dim strInternetID
	Dim strRefID
	Dim strRefID1
	Dim strRefID2
	Dim strExistingRefIDs
	Dim boolUseRefID1
	Dim boolUseRefID2

	Set objRoot = objMAPISession.GetFolder("")
	Set objBBRootFolder = objRoot.Folders.Item(gStrBlackBerryRootFolder)
	Set objBBCalSyncFolder = objBBRootFolder.Folders.Item(gStrBlackBerryCalSyncFolder)

	Set objMapHash = CreateObject("Scripting.Dictionary")

	Set objMessages = objBBCalSyncFolder.Messages

	For Each objMessage In objMessages
		strInternetID = GetMessageFieldValue(objMessage, gIntBBCalSyncCalID) & ""
		If strInternetID <> "[NULL]" Then
			strRefID1 = GetMessageFieldValue(objMessage, gIntBBCalSyncRefID1) & ""
			strRefID2 = GetMessageFieldValue(objMessage, gIntBBCalSyncRefID2) & ""
			boolUseRefID1 = True
			boolUseRefID2 = True
			If strRefID1 = "[NULL]" Then
				boolUseRefID1 = False
			End If
			If strRefID2 = "[NULL]" Then
				boolUseRefID2 = False
			End If
			If strRefID1 = strRefID2 Then
				boolUseRefID2 = False
			End If
			strRefID = ""
			If boolUseRefID1 = True Then
				If boolUseRefID2 = True Then
					strRefID = strRefID1 & ", " & strRefID2
				Else
					strRefID = strRefID1
				End If
			Else
				If boolUseRefID2 = True Then
					strRefID = strRefID2
				End If
			End If

			If strRefID <> "" Then
				' Now that the RefID(s) have been obtained, add or update the entry in the hashtable
				' For the internet message ID
				If objMapHash.Exists(strInternetID) Then
					strExistingRefIDs = objMapHash(strInternetID)
					strExistingRefIDs = strExistingRefIDs & ", " & strRefID
					objMapHash(strInternetID) = strExistingRefIDs
				Else
					objMapHash.Add strInternetID, strRefID
				End If
			End If
		End If
	Next
	Set GetBlackBerryMappings = objMapHash
End Function

Function GetMessageFieldValue(objMessage, fieldNameOrNumber)
	Dim fieldValue
	On Error Resume Next
	fieldValue = objMessage.Fields.Item(fieldNameOrNumber).Value
	If Err.Number <> 0 Then
		fieldValue = "[NULL]"
		Err.Clear
	End If
	On Error GoTo 0
	GetMessageFieldValue = fieldValue
End Function

Function ProcessFolder(objFolder, strGlobalFolder, objMapHash)

	Dim objSubFolder
	Dim objMessages
	Dim objMessage
	Dim objField

	Dim strMessageSender
	Dim strMessageRecipient
	Dim strMessageSubject
	Dim strMessageTimeSent
	Dim strMessageTimeReceived
	Dim strMessageCalendarRefID

	Dim arrInternetID

	Dim strLine

	Dim strCurrentFolder
	strCurrentFolder = strGlobalFolder & "\" & objFolder.Name

	For Each objSubFolder In objFolder.Folders
		ProcessFolder objSubFolder, strCurrentFolder, objMapHash
	Next

	Set objMessages = objFolder.Messages

	For Each objMessage In objMessages
		' Get standard message properties if they exist, otherwise set to nothing
		On Error Resume Next
		strMessageSender = objMessage.Sender
		If Err.Number <> 0 Then
			strMessageSender = "[NULL]"
			Err.Clear
		End If
		strMessageRecipient = objMessage.Recipient
		If Err.Number <> 0 Then
			strMessageRecipient = "[NULL]"
			Err.Clear
		End If
		strMessageSubject = objMessage.Subject
		If Err.Number <> 0 Then
			strMessageSubject = "[NULL]"
			Err.Clear
		End If
		strMessageTimeSent = objMessage.TimeSent
		If Err.Number <> 0 Then
			strMessageTimeSent = "[NULL]"
			Err.Clear
		End If
		strMessageTimeReceived = objMessage.TimeReceived
		If Err.Number <> 0 Then
			strMessageTimeReceived = "[NULL]"
			Err.Clear
		End If
		On Error GoTo 0

		strMessageCalendarRefID = GetMessageFieldValue(objMessage, gIntChangeKeyFieldNumber) & ""
		If strMessageCalendarRefID <> "[NULL]" Then
			If objMapHash.Exists(strMessageCalendarRefID) Then
				strMessageCalendarRefID = objMapHash(strMessageCalendarRefID)
			Else
				strMessageCalendarRefID = "[Not Found]"
			End If
		End If

		' Remove tabs and CF/LF from the subject if they managed to get in it
		strMessageSubject = Replace(strMessageSubject, vbTab, " ")
		strMessageSubject = Replace(strMessageSubject, vbCrLF, " ")

		strLine = strCurrentFolder & vbTab & strMessageSender & vbTab & strMessageRecipient & _
			vbTab & strMessageSubject & vbTab & strMessageTimeSent & vbTab & _
			strMessageTimeReceived & vbTab & strMessageCalendarRefID & vbTab

		' Get custom fields

		Dim strFieldName
		Dim strFieldValue

		For Each strFieldName in gArrFieldsToRead

			strFieldValue = GetMessageFieldValue(objMessage, strFieldName)
			If Len(Trim(strFieldValue)) = 0 Then
				strFieldValue = "[NULL]"
			End If

			strLine = strLine & strFieldValue & vbTab
		Next

		WScript.Echo strLine
	Next

End Function

Function CastANSIStringToUnicodeString(strANSIString)
	Dim strInString
	Dim strSubString
	Dim strOutString
	Dim intCharCount
	Dim intUnicodeCharCount
	Dim intANSIPosition
	Dim intUnicodePosition
	Dim intLeftChar
	Dim intRightChar
	Dim intCastChar

	strInString = strANSIString

	intCharCount = Len(strInString)

	' Pad out the string to an even number if necessary
	If intCharCount Mod 2 = 1 Then
		strInString = strInString & Chr(0)
		intCharCount = Len(strInString)
	End If

	intUnicodeCharCount = (intCharCount / 2) - 1

	For intANSIPosition = 0 to intUnicodeCharCount
		strSubString = Left(strInString, 2)
		If Len(strInString) > 2 Then
			strInString = Right(strInString, Len(strInString) - 2)
		End If

		' comment out the next line if by some coincidence this script is running on a big-endian system
		strSubString = StrReverse(strSubString)

		intLeftChar = Asc(Left(strSubString, 1))
		intRightChar = Asc(Right(strSubString, 1))

		' bitshift the left char left by 8, then add it to the right char
		intLeftChar = intLeftChar * 256
		intCastChar = intLeftChar + intRightChar

		strOutString = strOutString & ChrW(intCastChar)
	Next
	
	CastANSIStringToUnicodeString = strOutString
End Function
__________________
Legacy of Kain: The Lost Worlds
http://www.thelostworlds.net/

Last edited by blincoln : 08-09-2007 at 04:06 PM. Reason: Correct version number / datestamp / remove debugging code
Offline  
Old 08-16-2007, 04:01 AM   #14 (permalink)
New Member
 
Join Date: May 2007
Model: 7100V
PIN: N/A
Carrier: vodafone
Posts: 4
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi guys, my scripting knowledge is poor so looking for a hand!

I've run the script as I need to get some refID's out of a mailbox.

All I get is 3 prompts, which are handed out by the lines

WScript.Echo "Missing one or more arguments."
WScript.Echo "Usage: cscript -nologo DumpMailboxItemData.vbs28 [SERVER] [MAILBOX]"
WScript.Echo "Example: cscript -nologo DumpMailboxItemData.vbs mailserver01 blincoln"

do I just edit these lines and replace parts of them with the correct servername and mailbox or is there somewhere else I need to input these?

Any help greatly appreciated

Thanks

Paul
Offline  
Old 08-16-2007, 04:48 AM   #15 (permalink)
New Member
 
Join Date: May 2007
Model: 7100V
PIN: N/A
Carrier: vodafone
Posts: 4
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

it's ok guys, got it working now. saw the bit about running it from the command line and passing the parameters that way!!
Offline  
Old 10-26-2007, 01:31 AM   #16 (permalink)
New Member
 
Join Date: Oct 2007
Model: 810
PIN: N/A
Carrier: telstra
Posts: 2
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Problems Running Script

Hey Guys,

I have not much of a clue on scripting and was after some help ? I have got the updated script file which i basically saved as a .vbs file and tried to run with the suggested Syntax. I get an error saying
\DumpMailboxItemData1.vbs(364, 1) Microsoft VBScript compilation error: Expected statement

The syntax i used to run it was as follows
\cscript -nologo DumpMailboxItemData1.vbs server samaccountname > Output.txt


Anyhelp would be appreiated as we have a user that BES doesnt like and we are expeting it t be somthing dodgey in the mail account ?

Help
Shannon
Offline  
Old 10-26-2007, 01:36 AM   #17 (permalink)
New Member
 
Join Date: Oct 2007
Model: 810
PIN: N/A
Carrier: telstra
Posts: 2
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Update

Sorry guys just figured that line was -------------
I removed this and now get the following,

DumpMailboxItemData1.vbs(106, 2) Microsoft VBScript runtime error: ActiveX component can't create object: 'mapi.session
'

??Any help would be great

shannon
Offline  
Old 11-12-2007, 05:40 PM   #18 (permalink)
New Member
 
Join Date: Sep 2006
Location: New York
Model: 8100
Carrier: At&t
Posts: 14
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default RefId is not returned.

When trying to get RefID I get:
Collaboration Data Objects - [MAPI_E_NOT_FOUND(8004010F)]
for both items in gArrFieldsToRead.

Any ideas?
Offline  
Old 11-14-2007, 05:35 PM   #19 (permalink)
Thumbs Must Hurt
 
Join Date: Jul 2007
Location: city11 -inspectral
Model: 8100
PIN: N/A
Carrier: Cingular
Posts: 79
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

You are using the 1.2 version from later in the thread, right? If not, start by using that one. If that isn't the problem, try changing this line:

Const gCastFieldNamesANSIToUnicode = True

To:

Const gCastFieldNamesANSIToUnicode = False

...and see if it works then. I heard something about RIM supporting Unicode in one of the more recent BES service packs.
If it *still* doesn't work after that, which version of the BES are you on?
__________________
Legacy of Kain: The Lost Worlds
http://www.thelostworlds.net/
Offline  
Old 11-15-2007, 08:52 AM   #20 (permalink)
New Member
 
Join Date: Sep 2006
Location: New York
Model: 8100
Carrier: At&t
Posts: 14
Post Thanks: 0
Thanked 0 Times in 0 Posts
Cool Still no go!

Thanks blincoln, but it is to no avail!
I'm on BES 4.1.4 (Exchange).
I'm using the latest version here (1.2), but still getting the same issue with or without unicode flag being set.

A quick check of the mailbox using MDB Viewer (mdbvu32.exe) does not show any of the fields in gArrFieldsToRead (PR_RIM_MSG_REF_ID, PR_RIM_MSG_FOLDER_ID). I also tried looking for &H62030003 and &H62040003, but they are not there either. My device is definetley on the BES since I'm the BES "master"...

Also, I made a change to the script which some of the users my find useful - instead of EXCLUDE folders I added INCLUDE folders - so, if you want to check one folder quick, it would be much easier than specifying 50 folders to exclude.

I will post the mod as soon as I get the 2 fields to work..

Last edited by yk101 : 11-15-2007 at 08:53 AM. Reason: Addition of BES version.
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Copyright 2004-2014 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.