E
EHPorter
I have a macro which I use to extract information from my default outlook
contacts folder for a variety of purposes. It works well, BUT I also have a
lot of information stored in sub-folders within the Outlook Contacts folder.
All addresses for departments in Ramsey County, Minnesota, for example, are
stored in a
sub-folder called "Ramsey." How do I access these subfolders? Below is my
current test routine -- it accesses the main (default) Contacts folder and
just writes out a list of names and telephone numbers. How would I modify
the code to access a sub-folder?
In answering, keep in mind that I am relatively new at VBA and Outlook, and
can barely understand the code set forth below (even though I sort of wrote
it by modifying an example I got on the MVPs internet site)
Thank you.
****************Progress so far*********************
Private Sub GetOutlookInfo()
Dim oApp As Outlook.Application
Dim oNspc As NameSpace
Dim oItm As ContactItem
Dim ContactName As String
Dim FS As Object
Dim MyNewFile As Object
Set FS = CreateObject("Scripting.FileSystemObject")
Set MyNewFile = FS.CreateTextFile("c:\temp\testfile.txt", True)
Set oApp = CreateObject("Outlook.Application")
Set oNspc = oApp.GetNamespace("MAPI")
For Each oItm In oNspc.GetDefaultFolder _
(olFolderContacts).Items
ContactName = oItm.FullName
ContactName = ContactName + " " + oItm.BusinessTelephoneNumber
MyNewFile.writeline (ContactName)
Next oItm
MsgBox ("Script has run")
Set oItm = Nothing
Set oNspc = Nothing
Set oApp = Nothing
MyNewFile.Close
End Sub
******************************************************
contacts folder for a variety of purposes. It works well, BUT I also have a
lot of information stored in sub-folders within the Outlook Contacts folder.
All addresses for departments in Ramsey County, Minnesota, for example, are
stored in a
sub-folder called "Ramsey." How do I access these subfolders? Below is my
current test routine -- it accesses the main (default) Contacts folder and
just writes out a list of names and telephone numbers. How would I modify
the code to access a sub-folder?
In answering, keep in mind that I am relatively new at VBA and Outlook, and
can barely understand the code set forth below (even though I sort of wrote
it by modifying an example I got on the MVPs internet site)
Thank you.
****************Progress so far*********************
Private Sub GetOutlookInfo()
Dim oApp As Outlook.Application
Dim oNspc As NameSpace
Dim oItm As ContactItem
Dim ContactName As String
Dim FS As Object
Dim MyNewFile As Object
Set FS = CreateObject("Scripting.FileSystemObject")
Set MyNewFile = FS.CreateTextFile("c:\temp\testfile.txt", True)
Set oApp = CreateObject("Outlook.Application")
Set oNspc = oApp.GetNamespace("MAPI")
For Each oItm In oNspc.GetDefaultFolder _
(olFolderContacts).Items
ContactName = oItm.FullName
ContactName = ContactName + " " + oItm.BusinessTelephoneNumber
MyNewFile.writeline (ContactName)
Next oItm
MsgBox ("Script has run")
Set oItm = Nothing
Set oNspc = Nothing
Set oApp = Nothing
MyNewFile.Close
End Sub
******************************************************