A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Creating and naming a personal folder



 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old June 2nd 07, 05:34 PM posted to microsoft.public.outlook.program_vba
Mark Ivey
external usenet poster
 
Posts: 15
Default Creating and naming a personal folder

I am trying to create and name a personal folder. The code below will create
the folder and name the STORE or PST filename as I want, but I cannot seem
to figure out how to name the personal folder after (or while) it has been
created. It always shows up as "Personal Folders". Can someone point me in
the right direction?

I want the PST filename and the personal folder name to be the same.

TIA... Mark Ivey

__________________________________________________ _______________________________


Private Declare Function apiGetUserName Lib "advapi32.dll" Alias _
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long

Function fOSUserName() As String
' Returns the network login name
Dim lngLen As Long, lngX As Long
Dim strUserName As String
strUserName = String$(254, 0)
lngLen = 255
lngX = apiGetUserName(strUserName, lngLen)
If (lngX 0) Then
fOSUserName = Left$(strUserName, lngLen - 1)
Else
fOSUserName = vbNullString
End If
End Function

Sub Test()
On Error Resume Next
Dim objFolder As Outlook.MAPIFolder, objInbox As Outlook.MAPIFolder
Dim objNS As Outlook.NameSpace, objItem As Outlook.MailItem
Dim myFolder As String
Dim objUserName As String

myFolder = Format(Date, "yyyy")

Set objNS = Application.GetNamespace("MAPI")
Set objInbox = objNS.GetDefaultFolder(olFolderInbox)
Set objFolder = objNS.Folders(myFolder)

objUserName = fOSUserName


For Each objItem In Application.ActiveExplorer.Selection

If objFolder Is Nothing Then
objNS.AddStore "C:\Documents and Settings\" & objUserName & "\Local
Settings\Application Data\Microsoft\Outlook\" & myFolder & ".pst"
End If

Next

End Sub

__________________________________________________ _______________________________


 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to Sync Public Folder Contacts with Personal Folder Contact Li Larz Outlook - Using Contacts 0 May 14th 07 07:22 PM
'Naming' a hyperlink speedy_mike Outlook Express 10 April 23rd 07 06:56 PM
Outlook 2003 Calendar Naming/Properties internetsdave Outlook - General Queries 1 February 23rd 07 01:32 PM
properly creating Personal Folders RBB Outlook - General Queries 2 February 11th 07 04:02 PM
Naming distribution lists in Outlook MAQ Outlook - Using Contacts 2 October 16th 06 10:33 AM


All times are GMT +1. The time now is 11:35 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.