View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Jake Marx[_3_] Jake Marx[_3_] is offline
external usenet poster
 
Posts: 860
Default Outlook from Excel

Hi Scott,

Is it possible to retrieve all e-mails from a folder rather than all
e-mails that contain a word?


Yes. Here's some modified code that list the subject, from name, and
received time of all emails in a folder named "test":

Sub GetFromInbox()

Dim olApp As Outlook.Application
Dim olNs As NameSpace
Dim Fldr As MAPIFolder
Dim olMail As Outlook.MailItem
Dim i As Integer

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

For Each olMail In Fldr.Items
i = i + 1
ActiveSheet.Cells(i, 1).Value = olMail.Subject
ActiveSheet.Cells(i, 2).Value = olMail.SenderName
ActiveSheet.Cells(i, 3).Value = olMail.ReceivedTime
Next olMail

Set Fldr = Nothing
Set olNs = Nothing
Set olApp = Nothing

End Sub

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]