Zum Inhalt springen
Hilfe zu Outlook, Thunderbird, KuNoMail & Co.

Mail über Regel mit Script automatisch speichern

Überblick

Status
Beantwortet
Gefragt von
Unbekannt
Gefragt am
Antworten
1
Letzte Antwort
von Unbekannt

Frage

Hallo, ich habe hier ein Makro mit dem ich die Betreffzeile im Mail auslese und dann das Mail in einem definierten Ordner speicher. Bei der Erstellung einer Regel kann ich aber nur Script ausführen anwählen. Wie kann ich das hier beigefügte Makro als Script definieren?? Könnt ihr mir bitte einen Tip geben?
MfG René

Sub SaveAsTXT()
Dim myItem As Outlook.Inspector
Dim objItem As Object
Set myOlApp = CreateObject(\“Outlook.Application\“)
Set myItem = myOlApp.ActiveInspector
If Not TypeName(myItem) = \“Nothing\“ Then
Set objItem = myItem.CurrentItem
strname = objItem.Subject
strName = objItem.Subject
strName = Replace(strName, \“/\“, \“ \“)
strName = Replace(strName, \“\\\“, \“ \“)
strName = Replace(strName, \“:\“, \“ \“)
strName = Replace(strName, \“?\“, \“ \“)
strName = Replace(strName, Chr(34), \“ \“)
strName = Replace(sstrName, \“<\", \" \") strName = Replace(strName, \">\“, \“ \“)
strName = Replace(strName, \“|\“, \“ \“)
\’Prompt the user for confirmation
Dim strPrompt As String
strPrompt = \“Are you sure you want to save the item? If a file with the same name already exists, it will be overwritten with this copy of the file.\“
If MsgBox(strPrompt, vbYesNo + vbQuestion) = vbYes Then
objItem.SaveAs \“C:\\Technik & strname & \“.msg\“, olMSG
End If
Else
MsgBox \“There is no current active inspector.\“
End If

1 Antwort

1 Antwort anzeigen (von insgesamt 1)
  1. Hi,

    in den Regeln wird es nur angezeigt, wenn du dem Sub ein Argument des Typs Outlook.MailItem mitgibst.
    Ich hab das mal umgeschrieben, da es nicht der einzige Fehler war 😉

    Public Sub SaveAsTXT(myItem As Outlook.MailItem)
    strname = myItem.Subject
    strname = Replace(strname, \“/\“, \“ \“)
    strname = Replace(strname, \“\\\“, \“ \“)
    strname = Replace(strname, \“:\“, \“ \“)
    strname = Replace(strname, \“?\“, \“ \“)
    strname = Replace(strname, Chr(34), \“ \“)
    strname = Replace(strname, \“<\", \" \") strname = Replace(strname, \">\“, \“ \“)
    strname = Replace(strname, \“|\“, \“ \“)
    \’Prompt the user for confirmation
    Dim strPrompt As String
    strPrompt = \“Are you sure you want to save the item? If a file with the same name already exists, it will be overwritten with this copy of the file.\“
    If MsgBox(strPrompt, vbYesNo) = vbYes Then
    myItem.SaveAs \“C:\\Technik\“ & strname & \“.msg\“, Outlook.OlSaveAsType.olMSG
    Else
    MsgBox \“There is no current active inspector.\“
    End If
    End Sub

    Gruß

1 Antwort anzeigen (von insgesamt 1)
  • Sie müssen angemeldet sein, um zu diesem Thema eine Antwort verfassen zu können.