October 5, 2010
Hi David,
Yes you can. Have you changed the Email Account Name in the VBA to look at the folders for the account you are referring to?
To help any further I need to know the structure of your email folders, a screeenshot will do, and the name of the account that you want to search.
Phil
October 5, 2010
Hi David,
In Reply #4 of this thread I explained how to change the VBA. Open the file I created, press ALT+F11 to open the VBA editor then make the change.
Can I just clarify something. The code I've written will read emails from an email account that is setup up inside Outlook. It will not go and read emails from inside an OST that is disconnected from Outlook.
As you've supplied a screenshot of an OST in a folder, rather than the folders of an account in Outlook, I'm suspecting that this is what you are trying to do? Please confirm.
Just to reiterate, to read info from emails, the account you are trying to read those emails from must be set up and working inside Outlook.
Phil
December 5, 2016
Yes.
But still not working
Dim Folder As Object
Dim Email As Variant
Dim i As Integer
Set OutlookApp = CreateObject("Outlook.Application")
Set OutlookNS = OutlookApp.GetNamespace("MAPI")
' Insert the NAME of your email account - NOT the email address
Set Folder = OutlookNS.Folders("GKJ00OH004").Folders("Inbox")
i = 1
For Each Email In Folder.Items
Range("A1").Offset(i, 0).Value = Email.SenderName
Range("B1").Offset(i, 0).Value = Email.Subject
Range("C1").Offset(i, 0).Value = Email.ReceivedTime
Range("D1").Offset(i, 0).Value = Email.To
Range("E1").Offset(i, 0).Value = Email.CC
'' Range("F1").Offset(i, 0).Value = Email.Location
i = i + 1
Next Email
Set Folder = Nothing
Set OutlookNS = Nothing
Set OutlookApp = Nothing
End Sub
October 5, 2010
Hi David,
There seems to be some confusion which isn't helped by you not answering my questions.
The code I've written is to read emails from a folder from an account attached to Outlook. That account must be configured as a working account in Outlook.
I asked for a screenshot of your Outlook folders from inside Outlook but you sent a screenshot of folders in Windows Explorer on your hard drive.
The name of the folder in that screenshot was GKJ00OH004 - this is not the account name I am looking for. If you referred to the screenshots Marsil posted in the original thread this started in, you would see what I mean.
I have attached some samples below. You can see that the account name is John Smith and the email address is John.Smith@email.com.
If your OST file is not connected to Outlook and in use by an account then my VBA code will not work for you. OST files are offline stores and I do not know any way to open them from VBA. They are not the same as PST files. If you are trying to recover the emails because the OST file got disconnected from Outlook, you will probably need specialist recovery software to get them. I don't know any other way.
So you need to check in your Outlook what the name of the account is and that it is set up and working and that it is connected to the OST file pictured in your screenshot.
If you just want to read the Inbox then don't worry about a screenshot of the Outlook folders.
Regards
Phil
1 Guest(s)