Results 1 to 2 of 2
  1. #1
    New Lounger
    Join Date
    Jun 2002
    Thanked 0 Times in 0 Posts

    Access VBA to Outlook (Access 2000)

    I have an Access db that monitors incoming emails and creates database entries from them. I want to move the processed emails to a different folder, so that they don't get processed twice. Can anyone help with the code to make the move? I can copy the email across, but that leaves the original in place.
    thanks, Phil

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

    Re: Access VBA to Outlook (Access 2000)

    The MailItem object has a Move method, with the destination folder as argument.

    I use code like the following. When moving items, you must loop through the items in a folder backwards.

    Dim olApp As New Outlook.Application
    Dim olNamespace As Outlook.NameSpace
    Dim olInFolder As Outlook.MAPIFolder
    Dim olOutFolder As Outlook.MAPIFolder
    Dim olMI As Outlook.MailItem
    Dim n As Long
    Dim i As Long

    Set olNamespace = olApp.GetNamespace("MAPI")
    Set olInFolder = olNameSpace.GetDefaultFolder(olFolderInbox)
    Set olOutFolder = olNamespace.Folders("Personal Folders").Folders("Archive")

    n = olInFolder.Items.Count
    For i = n To 1 Step -1
    ' get i-th message
    Set olMI = olInFolder.Items(i)
    ' process message

Posting Permissions

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