ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   retreiving number of e-mails from public folder in Outlook (https://www.excelbanter.com/excel-programming/271959-retreiving-number-e-mails-public-folder-outlook.html)

Barmaley

retreiving number of e-mails from public folder in Outlook
 
With the help of Dick Kusleika and Chip Pearson I have managed to arrive to
this code, which checks e-mails in InBox. I couldn't figuire out how to
change
Set Fldr = olNs.GetDefaultFolder(olFolderInbox)
to extract e-mail info from Public Folder that reside on Exchange server.
Folder structure looks like this:
"Public Folders-All Public Folders-Custom Folder" etc (it has couple more
subfolders)

Can anyone help me please?


Sub GetFromInbox2()
Dim olApp As Outlook.Application
Dim olNs As NameSpace
Dim Fldr As MAPIFolder
Dim olMail As Variant
Dim i As Integer

Set olApp = New Outlook.Application
Set olNs = olApp.GetNamespace("MAPI")
Set Fldr = olNs.GetDefaultFolder(olFolderInbox)
i = 1

For Each olMail In Fldr.Items
If InStr(olMail.ReceivedTime, Range("F1")) 0 Then
ActiveSheet.Cells(i, 1).Value = olMail.ReceivedTime
i = i + 1
End If
Next olMail

Set Fldr = Nothing
Set olNs = Nothing
Set olApp = Nothing
End Sub




All times are GMT +1. The time now is 08:07 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com