?
Solved

Runtime Error 438 Object doesn't support this property or object

Posted on 2006-04-15
5
Medium Priority
?
974 Views
Last Modified: 2008-01-09
I am using the following code:
Private Sub btnNewMail_Click()
    Dim colItems        As Outlook.Items
    Dim objCurrentItem  As Object
    Dim strSQL          As String
    Dim dbs             As Database
    Dim tdf             As TableDef
    Dim rst             As DAO.Recordset
    Dim intDuplicates   As Integer
    Dim intI            As Integer
    Dim Attachment9     As String
   
    Dim dummy As String
   
On Error GoTo Error_btnNewMail_Click
    Set colItems = GetMailboxNetworkInput(Me.cmbMap, Me.cmbFolder)
   
    If colItems Is Nothing Then
        MsgBox "No items found"
    Else
        ' Return Database object variable pointing to current database.
        Set dbs = CurrentDb
        ' Return TableDef object variable pointing to Mail table.
        Set rst = dbs.OpenRecordset("Mail")
        ' Add to table Mail
        'DoCmd.Hourglass True
        DoCmd.SetWarnings False
        For Each objCurrentItem In colItems
            DoEvents
            If Not fncMailExist(objCurrentItem.EntryID) Then
                rst.AddNew
                rst!EntryID = objCurrentItem.EntryID
                rst!ReceivedTime = objCurrentItem.ReceivedTime
                rst!Subject = objCurrentItem.Subject
                rst!SenderName = objCurrentItem.SenderName
                rst!CC = objCurrentItem.CC
                rst!Body = fncReplaceTabs(objCurrentItem.Body)
                rst!Attachments = objCurrentItem.Attachments.Count
                'rst.Update
                'Save attachments in c:\temp
                Attachment9 = ""
                If objCurrentItem.Attachments.Count > 0 Then
                    For intI = 1 To objCurrentItem.Attachments.Count
                        objCurrentItem.Attachments.Item(intI).SaveAsFile ("T:\Cost Mailbox\Mail Attachments\" & objCurrentItem.Attachments.Item(intI))
                        Attachment9 = Attachment9 & "," & objCurrentItem.Attachments.Item(intI)
                    Next intI
                End If
                rst!AttachmentsName = Mid(Attachment9, 2)
                rst.Update
            Else
                intDuplicates = intDuplicates + 1
                If intDuplicates = 1 Then MsgBox "Duplicate emails were found.  These items will not be imported into the log."
            End If
        Next objCurrentItem
        DoCmd.SetWarnings True
        'DoCmd.Hourglass False
        rst.Close
        Set rst = Nothing
        Set dbs = Nothing
    End If
    Me.Refresh
    GoTo Exit_btnNewMail_Click

Error_btnNewMail_Click:
Select Case Err
    Case 3022, 6
        Resume Next
    Case Else
        MsgBox "Error: " & Err.Number & vbCrLf & Err.Description
End Select

Exit_btnNewMail_Click:
MsgBox "Emails have been logged into the Database.", vbOKOnly, "Get Emails"

End Sub

When I click on the button that runs this, I get "Error 438 Object doesn't support this property or object".  Can someone tell me why this is happening and how to fix it?
0
Comment
Question by:cobianna
  • 3
  • 2
5 Comments
 
LVL 44

Expert Comment

by:Leigh Purvis
ID: 16462924
You really need to (temporarily) remove your error handling to determine where the error is occuring.
Just comment out the line
'On Error GoTo Error_btnNewMail_Click

It could be occuring in your called procedures
GetMailboxNetworkInput, fncMailExist or fncReplaceTabs
0
 

Author Comment

by:cobianna
ID: 16464233
The error occured at the following line:
     rst!ReceivedTime = objCurrentItem.ReceivedTime

Any suggestions?
0
 
LVL 44

Expert Comment

by:Leigh Purvis
ID: 16464283
So I presume that GetMailboxNetworkInput returns the collection of mails from a specific folder in Outlook?
What is the code in GetMailboxNetworkInput ?

Is there a particular reason that you declare
Dim objCurrentItem  As Object
instead of
Dim objCurrentItem  As Outlook.MailItem

Does the collection not iterate if you do that?
0
 

Author Comment

by:cobianna
ID: 16464306
Here is the code for "GetMailboxNetworkInput":
Function GetMailboxNetworkInput(strMapNameLike As String, strFolderName As String) As Outlook.Items
    ' This procedure returns the items of the Outlook mailbox folder.                            *
    ' That is identified by:                                                                     *
    ' strMapNameLike = unique "Instr" part of MAP from outlook                                   *
    ' strFoldername  = name of folder                                                            *
    ' These variables have been specified to be able to identify the "Input" folder of the       *
    ' correct mailbox                                                                            *
    ' For the use within this application normally "Network" and "Input" will be specified       *
    Dim colMaps     As Outlook.Folders
    Dim colFolders  As Outlook.Folders
    Dim fldFolder   As Outlook.MAPIFolder
    Dim fldMap      As Outlook.MAPIFolder
   
    ' Use the InitializeOutlook procedure to initialize global
    ' Application and NameSpace object variables, if necessary.
    If golApp Is Nothing Then
        If InitializeOutlook = False Then
            MsgBox "Unable to initialize Outlook Application " _
                & "or NameSpace object variables!"
            Exit Function
        End If
    End If
   
    Set colMaps = gnspNameSpace.Folders
    For Each fldMap In colMaps
        If InStr(fldMap.Name, strMapNameLike) > 0 Then
            Set colFolders = fldMap.Folders
            For Each fldFolder In colFolders
                If fldFolder.Name = strFolderName Then
                    Set GetMailboxNetworkInput = fldFolder.Items
                    Exit Function
                End If
            Next fldFolder
        Set GetMailboxNetworkInput = Nothing
        End If
    Next fldMap
End Function

I did not create this code so I'm not sure why they would have used As Object instead of As Outlook.MailItem.
0
 
LVL 44

Accepted Solution

by:
Leigh Purvis earned 375 total points
ID: 16464563
Try switching the declaration for now - see if it highlights the problem any earlier (when you compile or first run it).
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
Windows Explorer lets you open cabinet (cab) files like any other folder. In VBA you can easily handle normal files and folders, but opening and indeed creating cabinet files takes a lot more - and that's you'll find here.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
Suggested Courses

850 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