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!

Can I Read Outlook Email in to a table or form

Status
Not open for further replies.

jbleoo

Technical User
Apr 22, 2003
14
US
I Receive many emails with formatted data in them from a website that I manage. The data comes in the body of mu email. I tried to import it into Access but only got the header info.

Please help.
Jason
 
Here are a few notes, but you will need something a bit fancier, if you want formatting:

Code:
Sub ListMail()
Dim olApp As Outlook.Application
Dim olNS As NameSpace
Dim olRecItems As Outlook.MAPIFolder
Dim olFilterRecItems As Items
Dim olNewMail As Outlook.MailItem
Dim strFilter As String
Dim dteLastCheck As Date
Dim dteThisCheck As Date
Dim strNewMessage As String
Dim i

'Dates to illustrate filter
dteLastCheck = DateAdd("d", -30, Now())
dteThisCheck = Now()

Set olApp = CreateObject("Outlook.Application")
Set olNS = olApp.GetNamespace("MAPI")

Set olRecItems = olNS.GetDefaultFolder(olFolderInbox)

'Note that there are no seconds in the filter and that
'the dates are text
strFilter = "[ReceivedTime] > " _
          & Chr(34) & Format(dteLastCheck, "mm/dd/yyyy hh:nn") & Chr(34) _
          & " AND [ReceivedTime] < " _
          & Chr(34) & Format(dteThisCheck, "mm/dd/yyyy hh:nn") & Chr(34)
Set olFilterRecItems = olRecItems.Items.Restrict(strFilter)

For i = 1 To olFilterRecItems.count
    Debug.Print _
    olFilterRecItems(i).ReceivedTime & vbCrLf _
    & olFilterRecItems(i).EntryID & vbCrLf _
    & olFilterRecItems(i).Body & vbCrLf
Next
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top