Erste Anlage aus outlook mit Access VBA

Ich habe einen erstellten Ordner in meinem outlook mit dem Namen "Reports". Dieser Ordner enthält E-Mails mit einem Anhang in jeder E-Mail. Ich möchte mit ACCESS VBA-speichern Sie die Anhänge aus dem "Berichte" - Ordner in Outlook auf einem lokalen Laufwerk in meinem computer. hier ist der code, den ich habe, so weit, aber gibt mir Fehler. Bitte helfen:

Sub GetAttachments()

Dim ns As NameSpace
Dim Inbox As Outlook.MAPIFolder
Dim folder As Outlook.MAPIFolder

Dim Item As Object
Dim Atmt As Attachment
Dim FileName As String
Dim i As Integer


Set ns = GetNamespace("MAPI")

Set Inbox = ns.Folders.Item("Reports") // I get an error in this line says an object could not be found 


i = 0

If Inbox.Items.Count = 0 Then
   MsgBox "There are no messages in the Inbox.", vbInformation, _
        "Nothing Found"
   Exit Sub
End If


For Each Item In Inbox.Items
   For Each Atmt In Item.Attachments
     FileName = "C:\Automation\" & Atmt.FileName

     Atmt.SaveAsFile FileName   // here is another error says method is not found
     i = i + 1
   Next Atmt
Next Item

InformationsquelleAutor guest1 | 2011-03-16

Schreibe einen Kommentar