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
Asterix VoIP Connection
Ubuntu - Convert Desktop Hard Drive to Laptop? Just ext4 format and copy all files?
reCAPTCHA PHP not failing when nothing is entered; works fine when something is entered
Excel/csv, move rows to another sheet based on changing value in column
Need a "quiz" application that saves to a database
Way to force data in Excel into the format I want?
Send Mail Using gmail pop3 in VB.Net
interpreting C++ code into VB.NET
How to configure Remote SPAN or alternative option on HP Procurve 2626-PWR switch ?
fully uninstall Acrobat 8.2.2