Results 1 to 2 of 2
  1. #1
    Star Lounger
    Join Date
    Mar 2003
    Summerville, South Carolina, USA
    Thanked 0 Times in 0 Posts

    Import from Outlook (Access 2000)

    (Edited by HansV to create link to MSKB article and to preserve indentation in code.)

    Microsoft has sample code under article <!mskb=253794>Microsoft Knowledge Base Article 253794<!/mskb> that shows how to import from outlook items when there are user defined fields involved. I have altered the code to my specifications in testing. My problem is the default folder that it imports from is my main mail folder. I need it to import from a separate mailbox named "Claims Report Request". I am not sure where or how to put this in my statement. This mailbox stores request forms in the form of a message. How do I reference this folder in my script? Thanks to any one that figure out this one. See Below the code I have right now.

    Sub ImportContactsFromOutlook1()

    ' This code is based in Microsoft Access.

    ' Set up DAO objects (uses existing "tblContacts" table)
    Dim rst As DAO.Recordset
    Set rst = CurrentDb.OpenRecordset("tblProject")

    ' Set up Outlook objects.
    Dim ol As New Outlook.Application
    Dim olns As Outlook.NameSpace
    Dim cf As Outlook.MAPIFolder
    Dim c As Outlook.MailItem
    Dim objItems As Outlook.Items
    Dim Prop As Outlook.UserProperty

    Set olns = ol.GetNamespace("MAPI")
    Set cf = olns.GetDefaultFolder(olFolderInbox)
    Set objItems = cf.Items
    iNumMessages = objItems.Count
    If iNumMessages <> 0 Then
    For i = 1 To iNumMessages
    If TypeName(objItems(i)) = "MailItem" Then
    Set c = objItems(i)
    rst!Contact_Name = c.SenderName

    ' Custom Outlook properties would look like this:
    ' rst!AccessFieldName = c.UserProperties("OutlookPropertyName")
    End If
    Next i
    MsgBox "Finished."
    MsgBox "No contacts to export."
    End If
    End Sub

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Thanked 31 Times in 31 Posts

    Re: Import from Outlook (Access 2000)

    Instead of

    Set cf = olns.GetDefaultFolder(olFolderInbox)


    Set cf= olns.Folders("Mailbox - Claims Report Request").Folders("Inbox")

    (replace Inbox by the name of the folder in the mail box you want to process)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts