X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
   Reply to this topicStart new topic
> Set Folder View Of Outlook Application From Access VBA, Office 2013    
post Oct 26 2018, 04:59 PM

Posts: 1
Joined: 9-December 17

I am using VBA in an Access module to create folders in Outlook.

The folders I create are located in a structured arrangement which has multiple layers (folder/subfolder/subfolder etc).

The code I have does this as I need, but the Outlook Application instance does not automatically set its folder view to display my new Outlook (sub) folder.

I need to be able to open the new folder from an access command button, but I can't figure out how to do it - and I find no helpful reference anywhere.

So my question is: How do (Can) I make Outlook set its active view to focus to a specified (sub)folder from Access VBA?

(Using Office 2016 but can only select 2013 in the Version drop-down here)

Thank you!
Go to the top of the page
post Oct 26 2018, 06:24 PM

Posts: 3,095
Joined: 4-February 07
From: USA, Florida, Delray Beach

Let's assume that you wanted to create an Instance of Outlook, open the 'Important' Folder that is one level under the Inbox, display the contents of the 'Important' Folder, then print the TO, SUBJECT, and BODY Fields for every E-Mail in that Folder:
Dim oOut As Outlook.Application
Dim oMailItem As Outlook.MailItem
Dim oFldr As Outlook.MAPIFolder

Set oOut = New Outlook.Application

'To access the 'Important' Folder under Inbox
Set oFldr = GetNamespace("MAPI").GetDefaultFolder(olFolderInbox).Folders("Important")

For Each oMailItem In oFldr.Items
  Debug.Print "TO: " & oMailItem.To
  Debug.Print "SUBJECT: " & oMailItem.Subject
  Debug.Print "BODY: " & oMailItem.Body
  Debug.Print "---------------------------------------------------------------------------"

Set oOut = Nothing
Set oMailItem = Nothing
Set oFldr = Nothing
Go to the top of the page

Custom Search

RSSSearch   Top   Lo-Fi    3rd August 2020 - 03:24 PM