Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Outlook from Excel ?????????????

Status
Not open for further replies.

Chance1234

IS-IT--Management
Jul 25, 2001
7,871
US
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




 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top