'Set Default Save Attachments in Outlook Express
'© Kelly's Korner - 7/16/03

Dim myShell, OE_ID, OE_ID2, OE_SA_Key, p1, cn, t, attPath, strCopy

Set myShell = CreateObject("WScript.Shell")

strCopyright = vbCR & vbCR & "Copyright 2003 - Kelly Theriot" & vbCR & "http://www.kellys-korner-xp.com"

On Error Resume Next
Message = "Select the default folder wanted. Note: You cannot select My Computer, Network Neighborhood or a root directory."

OE_ID = "HKEY_CURRENT_USER\Identities\Default User ID"
OE_ID2 = myShell.RegRead(OE_ID)

p1="HKEY_CURRENT_USER\Identities\" & OE_ID2 & "\Software\Microsoft\Outlook Express\5.0\Save Attachment Path"

Dim bffShell
	Dim bff
	Set bffShell = WScript.CreateObject("Shell.Application")
	Set bff = bffShell.BrowseForFolder(0, Message, 1)
	attPath = bff.ParentFolder.ParseName(bff.Title).Path
	cn = attPath & 	"...................................................................................................."

X = bff.title

If Err.Number = 424 AND X = "" AND attPath = "" Then
   MsgBox "You clicked Cancel, no changes were made." & strCopyright,  vbInformation, "User Cancelled"
   WScript.Quit
End If

ErrorNum = 1

If attPath = "" Then

   If X = "Desktop" Then
      ErrorNum = 0
   End If

   If X = "My Documents" Then 
      ErrorNum = 0
   End If

End If

If (Err.Number = 424 AND ErrorNum = 1) OR (Err.Number = 70) Then
   MsgBox "You selected an invalid entry!", 0, "Error!"
   WScript.Quit
End If


If Err.Number = 424 AND X = "My Documents" AND attPath = "" Then
   attPath = myShell.RegRead("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\Personal")
   cn = attPath & "...................................................................................................."
End If

If Err.Number = 424 AND X = "Desktop" AND attPath = "" Then
   attPath = myShell.RegRead("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\Desktop")
   cn = attPath & "...................................................................................................."
End If

Err.Clear

MyShell.RegWrite p1, cn, "REG_SZ"

If Err.Number <> 0 Then

   MsgBox "Error writing to the Registry!" & strCopyright, vbokonly + vbInformation,"Error!"	
   Wscript.Quit 

Else

   MsgBox "Save Attachment Path has been changed to " & vbCR & vbCR & attPath & strCopyright,  vbInformation, "Finished"
		
End If

