Microsoft
Software
Hardware
Network
Question : Excel VBA read an Outlook folder into Excel
I have the following Excel code which works fine for importing the Subject and Date Stamp of the items in my Inbox. I want to modify it to import from a sub-folder in my Inbox called "Tickets". Is there any way to do this?
Sub ListAllItemsInInbox()
Dim OLF As outlook.MAPIFolder, CurrUser As String
Dim EmailItemCount As Integer, I As Integer, EmailCount As Integer
Application.ScreenUpdating
= False
Sheets("Sheet1").Select
Cells.Clear
Range("A1").Select
' add headings
Cells(1, 1).Formula = "Subject"
Cells(1, 2).Formula = "Recieved"
With Range("A1:B1").Font
.Bold = True
.Size = 14
End With
Application.Calculation = xlCalculationManual
Set OLF = GetObject("", "Outlook.Application").Get
Namespace(
"MAPI").Ge
tDefaultFo
lder(olFol
derInbox)
EmailItemCount = OLF.Items.Count
I = 0: EmailCount = 0
' read e-mail information
While I < EmailItemCount
I = I + 1
If I Mod 50 = 0 Then Application.StatusBar = "Reading e-mail messages " & Format(I / EmailItemCount, "0%") & "..."
With OLF.Items(I)
EmailCount = EmailCount + 1
Cells(EmailCount + 1, 1).Formula = .Subject
Cells(EmailCount + 1, 2).Formula = Format(.ReceivedTime, "mm/dd/yyyy hh:mm")
End With
Wend
Application.Calculation = xlCalculationAutomatic
Set OLF = Nothing
End Sub
Answer : Excel VBA read an Outlook folder into Excel
Hi, malcolm29.
That's simple. Change this line of code
Set OLF = GetObject("", "Outlook.Application").Get
Namespace(
"MAPI").Ge
tDefaultFo
lder(olFol
derInbox)
to
Set OLF = GetObject("", "Outlook.Application").Get
Namespace(
"MAPI").Ge
tDefaultFo
lder(olFol
derInbox).
Folders("T
ickets")
Random Solutions
make a new bridge in cisco catalyst 2950
how to open the PDF in a new browser window using jsf ?
How to add safe senders in Outlook 2003 Junk filter using GPO
T-SQL: Count number of tables in the DB (SQL server 2008)
Pass multiple values for one parameter via OpenQuery
Make an Exception to Folder Redirect Group Policy Rule
using a hidden form with .hta script
OMA and OWA
SSH console: go to specified folder after login
Merge data in Access 2003