Can't get the Received Date on Outlook using VBA

Posted on 2009-04-06
Last Modified: 2012-05-06
I'm trying to retrieve all the emails from a specific folder from my MS Outlook including those in its subfolders.  Using the code below, I can get the Subject, To, Body, Importance but not the Received.  It just shows blank.  When I try to get the value using the immediate window, it says " Run-time error 438:  Object doesn't support this property or method."  I need to get the Received date so I can filter the date the emails were received.

I will appreciate any help!
Private Sub cmdRefresh_click()   

    Dim olApp As Outlook.Application

    Dim olNs As Outlook.NameSpace

    Dim strFolderPath As String    

    DoCmd.SetWarnings (False)

    DoCmd.RunSQL "Delete * from LastWeek"

    DoCmd.SetWarnings (True)           

    Dim RS As New ADODB.Recordset

    RS.Open "Emails", CurrentProject.Connection, adOpenDynamic, adLockOptimistic

    Set olApp = New Outlook.Application

    Set olNs = olApp.GetNamespace("MAPI")    

    Dim olFldr As Outlook.MAPIFolder     

    Set olFldr = olNs.GetDefaultFolder(olPublicFoldersAllPublicFolders).Folders("Transactions")    

    Call ProcessFolder(olFldr)

End Sub

Sub ProcessFolder(StartFolder As MAPIFolder)

    Dim objFolder As Outlook.MAPIFolder

    Dim objItem As Object

    Dim objEmail As MailItem

    Dim mailObject As Object

    Dim dtReceived As Date

    Dim strSubject As String

        On Error Resume Next

    Set objApp1 = Outlook.Application

    Set objNS1 = objApp1.GetNamespace("MAPI")

    Dim RS As New ADODB.Recordset

    RS.Open "LastWeek", CurrentProject.Connection, adOpenDynamic, adLockOptimistic


    For Each objItem In StartFolder.Items '.Folders           

            strSubject = objItem.Subject

            dtReceived = CDate(objItem.Received)

            If (InStr(1, strSubject, "Clothes;") > 0) Or _

                (InStr(1, strSubject, "Shoes") > 0) Then                            

                With RS


                    !Importance = objItem.Importance

                    !Subject = objItem.Subject

                    !from = objItem.SenderName

                    !To = objItem.To

                   ' ![Normalized Subject] = objItem.[Normalized Subject]

                    !Received = objItem.Received


                End With

            End If


        For Each objFolder In StartFolder.Folders

            Call ProcessFolder(objFolder)


End Sub

Open in new window

Question by:meredithf
1 Comment

Accepted Solution

meredithf earned 0 total points
ID: 24076687
I got it!  Should be objItem.ReceivedTime.


Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Office 365 Sync with office 2016 3 41
MS Office subscription 11 47
How to get AD RMS to work with Office 2016 for Mac 6 162
how to open abcd.txt.orig file? 10 44
Microsoft Office Picture Manager was included in Office 2003, 2007, and 2010, but not in Office 2013. Users had hopes that it would be in Office 2016/Office 365, but it is not. Fortunately, the same zero-cost technique that works to install it with …
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

896 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now