habe hier ein Makro zum Speicher von eingehenden Mails. Es wird im Betreff nach dem Wort Test gesucht.
Kann man das auch erweitern das man auch Mails mit dem Wort Test2 automatisch speichern lassen kann?
Habe alles probiert mit If Zeile Then Go To oder Or und es nichthinbekommen. Habt ihr eine Idee?
Private Sub Application_NewMailEx _
(ByVal EntryIDCollection As String)
Dim arr() As String
Dim i As Integer
Dim ns As Outlook.NameSpace
Dim itm As MailItem
Dim m As Outlook.MailItem
Dim MyBetreff As String
MyBetreff = "Test"
On Error Resume Next
Set ns = Application.Session
arr = Split(EntryIDCollection, ",")
For i = 0 To UBound(arr)
Set itm = ns.GetItemFromID(arr(i))
If itm.Class = olMail Then
Set m = itm
Set myItem = Application.Session.GetDefaultFolder(olFolderInbox).Items(1)
myItem.Display
strname = m.Subject
If InStr(1, strname, MyBetreff) = 0 Then
myItem.Close olSave
myItem.UnRead = True
Exit Sub
ElseIf InStr(1, strname, MyBetreff) 0 Then
strname = Replace(strname, ":", " ")
strname = Replace(strname, "/", " ")
End If
Dim strPrompt As String
m.SaveAs "O:\Diagnosen\" & strname & " " & "Datum" & "_" & Day(Date) & "_" & Month(Date) _
_
& "_" & Year(Date) & "_" & "Uhrzeit" & "_" & Hour(Time) & "_" & Minute(Time) & ".msg", olMSG
myItem.Close olSave
myItem.UnRead = True
End If
Next
Set ns = Nothing
Set itm = Nothing
Set m = Nothing
End Sub