PDA

View Full Version : Some folders not found in outlook



freshpoet
08-15-2018, 03:08 PM
Hi All,

This is a continuing from my previous code but where the a specific folder isnt found.

I am able to extract what I need from almost any folder in a shared mailbox except certain ones. I even tried my code on a different computer with a different user.

In the code below, I am unable to Set Folder = Folder.Folders("CHRISTINA"). The error message says that the object isnt found. However I am able to set a different at the same hierarchy with Set Folder = Folder.Folders("Anne").

Client support --> Inbox --> Anne works fine but not

Client support --> Inbox --> Christina.

Any ideas?

Thank you


Sub getDataFromOutlook()


Dim OutlookApp As Outlook.Application
Dim OutlookNamespace As Namespace
Dim Folder As MAPIFolder
Dim OutlookMail As Variant
Dim i As Integer


Dim strMailboxName As String


strMailboxName = "client support"




strMailboxName1 = "Inbox"






Set OutlookApp = New Outlook.Application


Set OutlookNamespace = OutlookApp.GetNamespace("MAPI")


Set Folder = OutlookNamespace.Folders("Client support")


Set Folder = Folder.Folders("Inbox")


Set Folder = Folder.Folders("CHRISTINA")






i = 1




For Each OutlookMail In Folder.Items






If OutlookMail.ReceivedTime >= Range("Start_of_Month").Value Then

If OutlookMail.ReceivedTime <= Range("End_of_Month").Value Then


Range("Email_Sender").Offset(i, 0) = OutlookMail.SenderName
Range("Email_Sender").Offset(i, 0).Columns.AutoFit
Range("Email_Sender").Offset(i, 0).VerticalAlignment = xlTop

Range("Email_Date").Offset(i, 0) = OutlookMail.SentOn
Range("Email_Date").Offset(i, 0).Columns.AutoFit
Range("Email_Date").Offset(i, 0).VerticalAlignment = xlTop


i = i + 1


End If

End If


Next OutlookMail




Set Folder = Nothing
Set OutlookNamespace = Nothing
Set OutlookApp = Nothing





End Sub

gmayor
08-15-2018, 09:31 PM
Is the folder named Folder.Folders("CHRISTINA")
or
Folder.Folders("Christina")
?

freshpoet
08-17-2018, 01:12 PM
Hey,

I managed to solve it by renaming the folder into a different name. The code is now able to find the Folder.

Thanks again!