excel vba - VBA code to reference my inbox in my archive - CLOSED -
i have code can used folder in primary inbox or inbox subfolder.
does know how reference archive folders or sent items? archive folder saved "my personal folders"
thank much
sub listallitems() dim olf outlook.mapifolder, curruser string dim emailitemcount integer, integer, emailcount integer application.screenupdating = false cells(1, 1).formula = "subject" cells(1, 2).formula = "recieved" cells(1, 3).formula = "attachments" cells(1, 4).formula = "recipients" cells(1, 5).formula = "sendername" range("a1:f1").font .bold = true .size = 14 end application.calculation = xlcalculationmanual set olf = getobject("", _ "outlook.application").getnamespace("mapi").getdefaultfolder(olfolderinbox).folders("toastmasters") emailitemcount = olf.items.count = 0: emailcount = 0 ' read e-mail information while < emailitemcount = + 1 if mod 50 = 0 application.statusbar = "reading e-mail messages " & _ format(i / emailitemcount, "0%") & "..." olf.items(i) emailcount = emailcount + 1 cells(emailcount + 1, 1).formula = .subject cells(emailcount + 1, 2).formula = format(.receivedtime, "dd.mm.yyyy hh:mm") cells(emailcount + 1, 3).formula = .attachments.count cells(emailcount + 1, 4).formula = not .unread cells(emailcount + 1, 4).formula = .recipients.count cells(emailcount + 1, 5).formula = .sendername end wend application.calculation = xlcalculationautomatic set olf = nothing columns("a:f").autofit range("a2").select activewindow.freezepanes = true activeworkbook.saved = true application.statusbar = false end sub
2st. set reference of archive folders should set follows:
set olf = getobject("", "outlook.application").getnamespace("mapi").folders("my personal folders")
where, optionally, instead of 'name' of folder use index number (usually 2 , more if have more archives).
1st. i'm not sure mean 'sent items'. asking folder sent items:
set olf = getobject("", "outlook.application").getnamespace("mapi").getdefaultfolder(olfolderssentmail)
Comments
Post a Comment