If you want to know the names of all the sub folders in Outlook Inbox.
Here is the code-
Option Explicit
Dim prnt As String
Sub print_folder_names_and_path_for_all_outlook_subfolder_in_inbox()
'tools->refrence->microsoft outlook
Dim olapp As Outlook.Application
Dim olappns As Outlook.Namespace
Dim oinbox As Outlook.Folder
Dim oFolder As Outlook.MAPIFolder
Set olapp = New Outlook.Application
Set olappns = olapp.GetNamespace("MAPI")
Set oinbox = olappns.GetDefaultFolder(olFolderInbox)
'Set oinbox = oinbox.Folders("Ashish")
For Each oFolder In oinbox.Folders
Call subfolders(oFolder)
Next
End Sub
Private Sub subfolders(oParent As Outlook.MAPIFolder)
Dim oFolder1 As Outlook.MAPIFolder
' you can add it to excel sheet or access table
MsgBox oParent.Name
'to know path
MsgBox oParent.FolderPath
'to know parent folder
MsgBox oParent.Parent
' mail count
MsgBox oParent.Items.Count
'unread mails count
MsgBox oParent.Items.Restrict("[UnRead] = True").Count
If (oParent.Folders.Count > 0) Then
For Each oFolder1 In oParent.Folders
Call subfolders(oFolder1)
Next
End If
End Sub
Subscribe to:
Post Comments (Atom)
Import data from SQL
Macro to import data from SQL using ADO connection string: Sub Import_data_from_SQL() ' Tools -> References -> Microsoft Active...
-
Macro to Export Range in Json Format Option Explicit Sub export_in_json_format() Dim fs As Object Dim jsonfile Dim rangetoex...
-
If you want to run SQL queries within Excel environment without connecting to any database, you can do it with creating the ADODB conn...
Please do visit Below links to Learn Outlook VBA
ReplyDeletehttp://www.outlookcode.com
http://www.jpsoftwaretech.com/
If you came know any other Site please share with us.