Jetzt weiss ich, was das Problem ist. Ich hatte das Option Explicit nicht an. Deswegen hat er bei mir nicht wegen der Variablen gemeckert.
Der Code also nochmals abschliessend:
Option Explicit
Sub SaveEmail()
Dim strPath As String
Dim strText As String
Dim obj As Object, objInspector As Object
strPath = "C:\Users\torsten.wetzel\Documents\Outlook Files\"
If TypeOf Application.ActiveWindow Is Outlook.Explorer Then
Set obj = Application.ActiveWindow
Set obj = obj.Selection(1)
Else
Set objInspector = ActiveInspector
objInspector.Activate
If objInspector.IsWordMail Then
Set obj = Application.ActiveInspector.CurrentItem
End If
End If
With obj
strText = Replace(.Subject, "/", "_")
strText = Replace(strText, "!", "")
strText = Replace(strText, ".", "_")
strText = Replace(strText, "\", "_")
strText = Replace(strText, ":", "_")
strText = Replace(strText, "(", "")
strText = Replace(strText, ")", "")
strText = Replace(strText, """", "")
.SaveAs strPath & Format(.ReceivedTime, "YYYY-MM-DD hh.mm") & " " & strText & ".msg", olMSG
End With
End Sub
|