ich habe ein schönes Coding gefunden für Excel das folgendes macht :
1. Prüfe in dem Outlook- Posteingang e-mails mit dem "Betreff" was inder Excel Datei in der Zelle "A1" vorhanden ist
2. Prüfe ob in der e-mail "Anhang" wie in der Zelle "B2" heisst.
3. Wenn ja dann speichere unter dem "Verzeichnis" was in der Zelle "C2"
steht.
Funktioniert einwandfrei, doch ich möchte dass jede E-mail auf mehrere Zeilen geprüft wird, sprich meherere Betreffe und Anhang-Bezeichnungen.
Hierzu brauche ich eine Schleife mit Variable , doch wie kann ich diese hier einbauen ?
Sub save_attachments()
Dim olook As Outlook.Application
Set olook = New Outlook.Application
Dim omail As Outlook.MailItem
Set omail = olook.CreateItem(olMailItem)
Dim ospace As Outlook.Namespace
Set ospace = olook.GetNamespace("MAPI")
Dim myfol As Outlook.Folder
Set myfol = ospace.GetDefaultFolder(olFolderInbox)
Dim atmt As Attachment
For Each omail In myfol.Items
If omail.Subject Like "*" & Range("A2").Value & "*" Then
For Each atmt In omail.Attachments
If atmt.Filename Like "*" & Range("B2").Value & "*" Then
atmt.SaveAsFile Range("C2").Value & atmt.Filename
Else
'do nothing
End If
Next
Else
'do nothing
End If
Next
End Sub