Access/Outlook automation error

Hi,
I have a database that downloads attachments from an outlook email folder; it's worked fine for about six months but now I get an automation error when I run it:

"Method 'Attachments' of object 'MailItem' failed -2147221233"

I have another database that does something similar and it has also started to receive the same error (code is below). I was wondering if a recent outlook update (or change to security settings?) might have caused this?

Thanks in advance for any help,
Gareth



Dim Ns As NameSpace
Dim myF As MAPIFolder
Dim miItem As Object
Dim Ol As New Outlook.Application
Dim Atmt As Attachment
Dim miProperty As Property
Dim FileName As String
Dim i As Integer
Dim x As Integer

On Error GoTo ErrDload
Set Ns = Ol.GetNamespace("MAPI")

Set myF = Ns.PickFolder
DownloadMail = False

If myF.Items.Count = 0 Then
Exit Function
End If

For Each miItem In myF.Items
If InStr(1, miItem.Subject, "Alert") Then
Debug.Print miItem.Subject
For Each Atmt In miItem.Attachments
FileName = IMPORTPATH & Atmt.FileName
Atmt.SaveAsFile FileName
i = i + 1
Next Atmt
End If
Next miItem
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories