Hi
I get the following error on the highlighted line of code...trying to run this to delete certain items out of my sent items folder after running some batch reports. Running this on access 97
The error is:
Run Time Error 13 'Type Mismatch'
I thought it might be because olMail hasn't been Set, but i cannot work out what to set it as...
Any clues?
I get the following error on the highlighted line of code...trying to run this to delete certain items out of my sent items folder after running some batch reports. Running this on access 97
The error is:
Run Time Error 13 'Type Mismatch'
I thought it might be because olMail hasn't been Set, but i cannot work out what to set it as...
Any clues?
Code:
Public Function test()
Dim OlApp As Outlook.Application
Dim OlMapi As Outlook.NameSpace
Dim OlFolder As Outlook.MAPIFolder
Dim olMail As Outlook.MailItem
Dim OlItems As Outlook.Items
'Dim OlAtch As Outlook.Attachment
Set OlApp = New Outlook.Application
Set OlMapi = OlApp.GetNamespace("MAPI")
Set OlFolder = OlMapi.GetDefaultFolder(olFolderSentMail)
Set OlItems = OlFolder.Items
[highlight]For Each olMail In OlItems[/highlight]
'If olMail.UnRead = False Then
If olMail.subject Like "*call centre data*" Then
'If LCase(OlMail.Subject) Like "*call center data*" Then
'If olMail.Attachments.Count > 0 Then
'For Each OlAtch In olMail.Attachments
'OlAtch.SaveAsFile "C:\FolderName\" & OlAtch.FileName
'Next OlAtch
'OlMail.Move OlMapi.GetDefaultFolder(olFolderDeletedItems)
olMail.Delete
'End If
'End If
End If
Next olMail
End Function