Set Homepage for New Folder in Outlook


E

ettiene.viljoen

All,

I have managed to use a vbscript to create a new folder in all user
Outlook, I need to go one step further and set the hompepage to a
spesific URL we have 2000 users so going around to the desktops do not
appeal :)

Below is an overview of the script being used and the folder creation
function
' OVERVIEW
' This script has been designed to enumerate users only in a specific
OU (OU is determined by user input when executing the script) once
complete, AD is queried for the users mailbox.
' Following the above, users and their mailbox id are used to call a
function, during the function
' the users mailbox is accessed to check for folder names that exists
in the root of their mailbox,
' all folder names are output, per user, to a text file (location
determined by user input). If the
' referenced folder name does not exists it is created, followed by a
cross check to confirm it has
' been created correctly.

'Folder Creation Function
' **********************

Function CreateMailFolder(aMailhome, sLogon, sFoldername,
sFileLocation)

dim application, cdosession
dim strProfileInfo
dim objFolder, folder
Dim cdoInfoStore, cdofolderstore, objsession, objFolders, FindFolder,
ObjStore, aNames, readtext, text, f, fso, of

set cdosession = createobject("mapi.session")

strProfileInfo = aMailhome & vbLf & sLogon
cdosession.Logon "", "", False, True, 0, False, strProfileInfo

If Err.Number = 0 Then
' wscript.echo Err.Number
End If

Set objFolder = cdosession.Inbox
Set objstore = cdosession.Getinfostore(CDOsession.Inbox.storeid)

If objFolder Is Nothing Then
wscript.echo "Failed to open Inbox"
End If

const ForReading = 1, ForWriting = 2, ForAppending = 8
Set fso = CreateObject("Scripting.FileSystemObject")

If fso.FolderExists(sFileLocation) Then

Else
Set objFolder = fso.CreateFolder(sFileLocation)
End If

Set f = fso.OpenTextFile(sFileLocation & "\" & sLogon & ".txt",
ForWriting, True)
Set of = fso.OpenTextFile(sFileLocation & "\" & sLogon & ".txt",
ForReading, True)

For Each objFolders In objstore.rootfolder.folders
f.writeline objFolders.name
Next

f.writeline "****First Read Complete***"
f.writeline ""

readtext = of.ReadAll
text = "_Message Centre"

If InStr (readtext, text) Then
wscript.echo "Folder Already Exists for - " & sLogon
else
set folder = objstore.RootFolder.Folders.Add(sFoldername ,6)
wscript.echo "Folder will be created for - " & sLogon
oErr = 22
CreateMailFolder = err.number
End If

If oErr = 22 Then
For Each objFolders In objstore.rootfolder.folders
'wscript.echo objfolders.name
f.writeline objFolders.name
Next
readtext = of.ReadAll
If InStr (readtext, text) Then
wscript.echo "Folder has been successfully created for " & sLogon
else
wscript.echo "Folder was not successfully created for - " & sLogon
CreateMailFolder = err.number
End If
End If

Set fso = Nothing
Set f = Nothing
Set readtext = Nothing
Set text = Nothing
Set of = Nothing

End Function
 
Ad

Advertisements

S

Sue Mosher [MVP-Outlook]

Since you're using CDO to create the folders, you'll need to work with their MAPI properties, through the Fields collection, as shown at http://www.cdolive.com/cdo10.htm

Outlook Spy reveals that the MAPI property that contains the information about the folder home page is PR_FOLDER_WEBVIEWINFO (0x36DF0102) and that the binary (Unicode) parses out into these different components:

dwVersion: 0x00000002
dwType: 0x00000001
dwFlags: 0x00000001
dwUnused: 0x0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000
cbData: 0x36 (00000024)
bData: http://theurl.com

The variable portions are dwType, which will be 0 if the home page is on and 1 if it's off, and bData, which is your URL.
--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top