Sub Emails_In_Inbox()
'***************************************************************
'* Set a refernce to the Outlook before running this procedure *
'* *
'* This will list all of the emails in the Inbox onto the *
'* current sheet, be sure to have an empty sheet selected *
'***************************************************************
' Variable Declaration
Dim inbox As Outlook.MAPIFolder, user As String
Dim i As Integer, mail As Integer, mails As Integer
Application.ScreenUpdating = False
Cells.Delete
' Headings
[A1] = "From": [B1] = "Subject": [C1] = "Attachments": [D1] = "Contents"
With [A1:D1].Font
.Bold = True
End With
Application.Calculation = xlCalculationManual
Set inbox = GetObject("", "Outlook.Application") _
.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox)
mails = inbox.Items.Count
i = 0: mail = 0
' Extract Email Information
Do While i < mails
i = i + 1
With inbox.Items(i)
mail = mail + 1
Cells(mail + 1, 1).formula = .SenderName
Cells(mail + 1, 2).formula = .Subject
Cells(mail + 1, 3).formula = .Attachments.Count
Cells(mail + 1, 4).formula = .Body
End With
Loop
' Clean Up
Set inbox = Nothing
Cells.Columns.AutoFit
Cells.Rows.AutoFit
[A1].Select
With Application
.Calculation = xlCalculationAutomatic
.ScreenUpdating = True
End With
End Sub
[code]
This will import information from the emails in your inbox (From, Subject, # of Attachments & Email Text) to the active sheet (be sure that it is empty before testing).
To do somthing like this in Access, you can import directly from an Outlook folder into an Access table, just select [b]Outlook()[/b] in the FileType field first and then select the folder that contains the emails that you want to import. You can also link the folder to the Access database as well. This is all found under [b]File->External Data[/b]. You will have to set up the table to contain only the data that you want though.
I hope that these solutions help!
Peace! [peace]
Mike
[COLOR=red][b]Never say Never!!!
Nothing is impossible!!![/b][/color]