Chance1234
IS-IT--Management
Hi can anyone tell me why this code isnt working, i tested it using the inbox and getdefaultfolder, but im nwo trying to reference a public folder and it is not working.
sub psubcompared()
Dim myOutlook As Outlook.Application
Dim ns As Outlook.NameSpace
Dim fld As Outlook.MAPIFolder
Dim itms
Dim itm As Object
Dim mymail As Outlook.Items
'-----------Good old excel
Dim EmailArr()
Application.ScreenUpdating = False
Set olOutlook = CreateObject("Outlook.Application"
Set ns = olOutlook.GetNamespace("MAPI"
Set itms = ns.Folders("Public Folders"
Set itms = itms.Folders("All Public Folders"
Set itms = itms.Folders("BCDE"
Set itms = itms.Folders("IT Dept"
Set itms = itms.Folders("Global"
Set itms = itms.Folders.Item("Paris Sales Responses"
Set mymail = itms
EmailArr = shtDist.Range("a1:n1516".CurrentRegion
x = 1
MsgBox mymail.Count
Do Until x = UBound(EmailArr)
' Debug.Print EmailArr(x, 2)
Y = 1
For Each mymail In itms
If mymail.SenderName Like EmailArr(x, 5) Then
EmailArr(x, 3) = EmailArr(x, 3) & " # " & mymail.Subject
End If
Next
x = x + 1
Loop
Range("a1:n1516".Value = EmailArr
Set olOutlook = Nothing
Set ns = Nothing
Set itms = Nothing
Set mymail = Nothing
End Sub
sub psubcompared()
Dim myOutlook As Outlook.Application
Dim ns As Outlook.NameSpace
Dim fld As Outlook.MAPIFolder
Dim itms
Dim itm As Object
Dim mymail As Outlook.Items
'-----------Good old excel
Dim EmailArr()
Application.ScreenUpdating = False
Set olOutlook = CreateObject("Outlook.Application"
Set ns = olOutlook.GetNamespace("MAPI"
Set itms = ns.Folders("Public Folders"
Set itms = itms.Folders("All Public Folders"
Set itms = itms.Folders("BCDE"
Set itms = itms.Folders("IT Dept"
Set itms = itms.Folders("Global"
Set itms = itms.Folders.Item("Paris Sales Responses"
Set mymail = itms
EmailArr = shtDist.Range("a1:n1516".CurrentRegion
x = 1
MsgBox mymail.Count
Do Until x = UBound(EmailArr)
' Debug.Print EmailArr(x, 2)
Y = 1
For Each mymail In itms
If mymail.SenderName Like EmailArr(x, 5) Then
EmailArr(x, 3) = EmailArr(x, 3) & " # " & mymail.Subject
End If
Next
x = x + 1
Loop
Range("a1:n1516".Value = EmailArr
Set olOutlook = Nothing
Set ns = Nothing
Set itms = Nothing
Set mymail = Nothing
End Sub