Read mail's Subject

Maurizio

Well-known Member
Joined
Oct 15, 2002
Messages
691
Office Version
  1. 2007
Platform
  1. Windows
Hi all,
is it possible read, with vba, all "Subject" from my received mails (Outlook Express 6.0) on 05/05/2003 and report them on a sheets?

Tia.
 
I tried to add this into the macro
Set MySubFolder = NmSpace.Folders("Public Folders").Folders("All Public Folders").Folders("Mycompany").Folders("State").Folders("nac dcs swap").Folders("Clients Emp Changes")
But I am getting an object could not be found error.
I checked all spelling and ensure case sensitivity.
 
Upvote 0

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
It's just a matter of drilling down. Try this (which worked for me):

Code:
Sub Test()
    Dim OutApp As Object    'Outlook.Application
    Dim NmSpace As Object   'Outlook.NameSpace
    Dim Folder As Object    'Outlook.MAPIFolder
    Dim MItem As Object     'Outlook.MailItem
    Set OutApp = CreateObject("Outlook.Application")
    Set NmSpace = OutApp.GetNamespace("MAPI")
    For Each Folder In NmSpace.Folders("Public Folders").Folders("All Public Folders").Folders
        MsgBox Folder.Name
    Next Folder
    Set Folder = Nothing
    Set NmSpace = Nothing
    Set OutApp = Nothing
End Sub

If you are happy that some folders exist under All Public Folders, keep expanding the tree until you get an error.
 
Upvote 0
drilling down worked!!!!! it appears i misspelled a word by transposing two letters!

Now, I have it working, but it is only returning the contents of one folder, not all three...How can I resolve this?
 
Upvote 0
I think you'll have to do one at a time. After the first pass Set the MySubFolder variable to the next folder you want and repeat the For Each MItem loop.
 
Upvote 0

Forum statistics

Threads
1,221,310
Messages
6,159,176
Members
451,543
Latest member
cesymcox

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top