Outlook from Excel

  • Thread starter Thread starter scottnshelly
  • Start date Start date
S

scottnshelly

I remember seeing the code for this before, but i can't seem to find it
any suggestions would be great.
I need to pull all emails that contain a certain word or from a certai
folder and put them onto a spreadsheet.
should be pretty simple for you smart guys, but i have no idea where t
begin.
thanks
 
Is it possible to retrieve all e-mails from a folder rather than al
e-mails that contain a word
 
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]
 
Thanks,
Now i have this code that pulls all the e-mails from a folder name
'terms' and puts them into different cells in the same column the
prints. the problem is, i only need one four-digit number from eac
cell. so i end up printing way too many pages than neccessary. is i
possible to only print the four-digit number from each e-mail/cell?
Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top