Create Outlook Profiles via Script

K

kc2kth

Is anyone familiar with a method and the appropriate settings to
create an Outlook profile from a script? I'm looking for a way to
script creation of an Outlook profile specifying the mailbox (it will
not be the mailbox of the logged in user), then performing some tasks,
then removing the profile once complete. I need to loop through this
process for a large number of mailboxes - several thousand.

Client will be Outlook 2003 working against Exchange 2003 backend.

The goal is to create a specific folder for all mailboxes in the
Exchange organization.

Thanks in advance!
 
K

kc2kth

I'd use CDO 1.21 and dynamic profiles. Start athttp://www.cdolive.com

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54

Sue,

Found most of what I was looking for at that site. Thank you very
much!

I'm stuck on one concept however. I'm attempting to use the dynamic
profile option and login:

' Or, logon using an new MAPI session with a dynamically created
profile
strProfileInfo = "<Your Servername>" & vbLf & "<Your Mailbox>"
objSession.Logon "", "", False, True, 0, False, strProfileInfo

Plugging in the appropriate info for server name and mailbox, I'm
getting prompted to select one of my existing Outlook (2003, SP2)
profiles. Deleting those profiles and running the script again, I now
am prompted to create an Outlook profile.

I'm guessing something in the above code is not working. Unfortunately
I'm not sure where to look from here.

Prior to plugging in my own code into the sample code, I was able to
use the sample code to send an email from the correct profile. I can't
quite figure out why it worked to send an email, but now not when I
try to create a folder. My complete code is below:
 
K

kc2kth

Sue,

Found most of what I was looking for at that site. Thank you very
much!

I'm stuck on one concept however. I'm attempting to use the dynamic
profile option and login:

' Or, logon using an new MAPI session with a dynamically created
profile
strProfileInfo = "<Your Servername>" & vbLf & "<Your Mailbox>"
objSession.Logon "", "", False, True, 0, False, strProfileInfo

Plugging in the appropriate info for server name and mailbox, I'm
getting prompted to select one of my existing Outlook (2003, SP2)
profiles. Deleting those profiles and running the script again, I now
am prompted to create an Outlook profile.

I'm guessing something in the above code is not working. Unfortunately
I'm not sure where to look from here.

Prior to plugging in my own code into the sample code, I was able to
use the sample code to send an email from the correct profile. I can't
quite figure out why it worked to send an email, but now not when I
try to create a folder. My complete code is below:

Hit send while trying to get back to my code. Here it is:

' Create MAPI session
Dim objSession
Set objSession = CreateObject("MAPI.Session")

' Or, logon using an new MAPI session with a dynamically created
profile
strProfileInfo = "server" & vbLf & "LeMay, John"
objSession.Logon "", "", False, True, 0, False, strProfileInfo


'********************************************************

SetupFolderHomePage "My Custom Folder","http://webserver"


Sub SetupFolderHomePage(foldername,url)
Set outApp=CreateObject("Outlook.Application")

Set nsp = outApp.GetNamespace("MAPI")
Set mpfInbox = nsp.GetDefaultFolder(6)
On Error Resume Next
Set mpfNew = mpfInbox.Parent.Folders.Add(foldername)
ErrMsg
mpfNew.WebViewURL = url
mpfNew.WebViewOn = True
End Sub

Sub ErrMsg
If err.number <> 0 then
wscript.echo "An Error has Occured"
wscript.echo "Most likely the folder already exists"
wscript.echo "Error Detail: "&Err.Number
Err.clear
end if

End Sub


'********************************************************

' Logoff from MAPI Session
objSession.Logoff
 

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