Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to load emails from a folder (not the inbox) to a table.

Status
Not open for further replies.

colezpapa3

Programmer
Dec 8, 2007
73
US
We have a group email box where work requests are sent.
I want to load the emails from that email folder into a table in a database to assign and track.
I have done this with the inbox but not with a different folder, can this be done.
 
Some notes that may help.

Code:
Dim oMsg As Object
Set objOutlook = CreateObject("Outlook.Application")
Set objNamespace = objOutlook.GetNamespace("MAPI")

For Each m In objNamespace.Folders
  If m.Name = "Personal Folders" Then
    For Each n In m.Folders
      If n.Name = "Deleted Items" Then
        Set oFolder = n
        Exit For
      End If
    Next
  Exit For
  End If
Next

For Each oMsg In oFolder.Items
  Debug.Print oMsg
Next
 
If my Group Mailbox was #Specialists Group how would I code that. The mail from that mailbox ends up in the individual inbox.
 
I am not sure. Is the mailbox you wish to access listed when you run this code:

Code:
Sub ListFolders()
'Needs a reference to the Outlook library
Dim olAp As Outlook.Application
Dim ns As Outlook.NameSpace
Dim fldrparent As MAPIFolder
Dim fldrs As Folders
Dim fldr As MAPIFolder

Set olAp = CreateObject("Outlook.Application")
Set ns = olAp.GetNamespace("MAPI")

Set fldrparent = ns.GetDefaultFolder(olFolderInbox).Parent

Set fldrs = fldrparent.Folders

If fldrs.Count > 0 Then
    Set fldr = fldrs.GetFirst

    While Not fldr Is Nothing
        Debug.Print fldr

        Set fldr = fldrs.GetNext
    Wend
End If
End Sub
 
Hi

No, that one is not listed. The following are listed.
What does that mean if it' not listed.

Deleted Items
Drafts
Inbox
Journal
Junk E-mail
Notes
Outbox
Sent Items
Tasks
 
AFAIK, that it is not a personal folder.
 
I took out my trusty Access 2003 Roger Jennings book and he suggests to link to the mailbox thru the Exchange/Outlook wizard. I did it and its a piece of cake. Now I have that folder as a table in my Access app.
Is this not a good way to do this, because it was too easy.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top