ich verwende ein Makro um Anhänge aus meinem Postfach zu speichern.
Das Makro überprüft den Betreff der E-Mails und bei Übereinstimmung mit einem vorgegeben String, wird der Anhang auf die Festplatte heruntergeladen. Das funktioniert auch soweit einwandfrei seit langer Zeit.
Ich möchte das Makro jetzt dahingehend erweitern, dass es auf ein mit anderen Personen geteiltes Postfach zugreift. Es scheint so, als würde mein Makro nur auf meine Hauptpostfach zugreifen?
Ich weiß leider nicht an welcher Stelle ich eine anderes Postfach angeben kann.
Hier der Code:
Sub AnhängeSpeichernVonBestimmtenMails()
Dim objOutApp As Outlook.Application
Dim objOutNameSpace As Namespace
Dim objOutMapi As MAPIFolder
Dim objOutMail As Variant
Dim lngz As Long
Dim lngAnzahl As Long
Set objOutApp = New Outlook.Application
Set objOutNameSpace = objOutApp.GetNamespace("MAPI")
Set objOutMapi = objOutNameSpace.GetDefaultFolder(olFolderInbox)
For Each objOutMail In objOutMapi.Items
If objOutMail.Class = olMail Then
With objOutMail
lngAnzahl = .Attachments.Count
If lngAnzahl > 0 And objOutMail.Subject = "test" Then
For lngz = 1 To lngAnzahl
.Attachments.Item(lngz).SaveAsFile ThisWorkbook.Path & "\" & .Attachments. _
Item(lngz).Filename
Next lngz
End If
End With
End If
Next objOutMail
MsgBox "Fertig"
Set objOutMapi = Nothing
Set objOutNameSpace = Nothing
Set objOutApp = Nothing
End Sub
Weiß jemand wo ich eine andere Postfach anzugeben habe?
Eigentlich müsste diese Anpassung doch möglich sein, oder?
Besten Dank im Voraus für jede Hilfe/Hinweis.
Beste Grüße
Norbert