Hiya,
I have some code scanning an inbox on a shared email via exchange (through outlook 2003). That part works fine. I am using objects rather than the referenced code. I have set a variable to point to the folder. It seems to be correct, but when I use the mail item .move method it errors with type mismatch 13.
Below are the relevant parts of the code...
Am I missing something easy?
Code:Dim objOL As Object, ns As Object Dim strFolderPath As String Dim strData As String Dim fInbox As Object Dim fArchived As Object Dim fProblem As Object Dim f As Object Dim mi As Object Dim blnProblemEmail As Boolean, blnAlreadyImported As Boolean, blnDup As Boolean Dim blnSkipAll As Boolean Dim rst As DAO.Recordset, rstSub As DAO.Recordset Dim strSql As String, strFld As String Dim varEmail As Variant, varLine As Variant Dim lngEmailLines As Long, lngEmailOn As Long, lngLineParts As Long, lngLinePrt As Long, lngNumberOfFields As Long Dim strChassis As String, strFileID As String '---- outlook On Error Resume Next Set objOL = GetObject(, "Outlook.Application") If Err.Number <> 0 Then Err.Clear Set objOL = CreateObject("Outlook.Application") End If On Error GoTo 0 Set ns = objOL.GetNamespace("MAPI") If fraEmailBoxes = 1 Then strFolderPath = "Mailbox - A" 'renamed but this bit does work Else strFolderPath = "Mailbox - B" End If On Error Resume Next Set f = ns.Folders(strFolderPath) If Err.Number <> 0 Then MsgBox "You do not appear to have outlook running or access to the required folder/email box", vbOKOnly + vbInformation blnSkipAll = True End If On Error GoTo 0 '---- lists all folders in namespace ' For Each f In ns.Folders ' Debug.Print f.Name ' Next If Not blnSkipAll Then If fraEmailBoxes = 1 Then Set fInbox = f.Folders("Inbox") Set fArchived = fInbox.Folders("Archived") Set fProblem = fInbox.Folders("Problem") Else Set fInbox = f.Folders("Inbox") Set fArchived = fInbox.Folders("Archived") Set fProblem = fInbox.Folders("Problem") End If DoCmd.Hourglass True For Each mi In fInbox.items blnProblemEmail = False strChassis = "" strFileID = "" blnAlreadyImported = False blnDup = False lngNumberOfFields = 0 '---- other code here to determing the problem email (or not) If blnProblemEmail Then '---- move to problem folder mi.Move (fProblem) Else '---- move to archived folder mi.Move (fArchived) ' <<<< problem is on this line End If DoEvents Next DoCmd.Hourglass False End If '---- clean up Set fInbox = Nothing Set fArchived = Nothing Set fProblem = Nothing Set ns = Nothing Set objOL = Nothing




Reply With Quote