[AccessD] [Spam]8.51 Re: Get sender's eMail address

William Benson (VBACreations.Com) vbacreations at gmail.com
Wed Aug 31 13:56:12 CDT 2011


This works from Access with a reference to Outlook only... Note I have a pst
folder called GMAIL and I am searching Inbox... change to suit.


Dim myOlApp As Object
Dim myNameSpace As Object
Dim myfolders As Object
Dim MyFolder As Object
Dim myfolder2 As Object
Dim item As Object

Dim n As Long


Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNamespace("MAPI")
Set myfolders = myNameSpace.Folders

n = 1
Do Until UCase(myfolders.item(n).Name) = "GMAIL"
  n = n + 1
Loop

Set MyFolder = myfolders.item(n)
Set myfolder2 = MyFolder.Folders("Inbox")

For Each item In myfolder2.Items
  If item.Class = 43 Then
    Debug.Print item.SenderEmailAddress
  End If
Next item


End Sub





More information about the AccessD mailing list