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

VBA zum automatischen Speichern von Mails

Überblick

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

Frage

Hallo!

Als aboluter VBA Dau bin ich auf der Suche nach Unterstützung für ein kleines (ich denk mir mal es kann für jemand der Verständnis von der Materie hat keine Hexerei sein) VBA Script für folgende Aufgabenstellung.
Ich erhalte mehrmals täglich von einem besteimmten Absender Mails die ich als *.msg auf einem Netzlaufwerk speichern möchte.
Der Datei Name soll aus dem Betreff bezogen werden.
Kann mir hier jemand ein paar Tips geben?

Vielen Dank
Kidjo

1 Antwort

1 Antwort anzeigen (von insgesamt 1)
  1. das habe ich gefunden (vielleicht hilft es):
    Hier mal ein Vorschlag:

    Dim WithEvents colInspectors As Outlook.Inspectors
        
    Private Sub Application_Startup()
        Set colInspectors = Application.Inspectors
    End Sub
    
    Private Sub colInspectors_NewInspector(ByVal Inspector As Inspector)
        \' your code to work with Inspector goes here
        \' if you want to work with the actual item that\'s opened,
        \' use this:
    \'Dim objItem As Object
    \'Set objItem = Inspector.CurrentItem
    
    Dim myolApp As Object
    Dim myMessageItem As Object
    Dim myAttachmentItems As Object
    Dim myJobnumber As String
    Dim MyDrive As String
    Dim Title As String
    
    Set myolApp = CreateObject(\"Outlook.Application\")
    Set myMessageItem = Inspector.CurrentItem
    Set myAttachmentItems = myMessageItem.Attachments
    
    With myMessageItem
    
     \'basic info about message
                Debug.Print .To
                Debug.Print .CC
                Debug.Print .Subject
                Debug.Print .Body
                If .UnRead Then
                    Debug.Print \"Message has not been read\"
                Else
                    Debug.Print \"Message has been read\"
                End If
                
    myJobnumber = InputBox(\"Title prefix?\", Title, \"99999\")
        
    If myJobnumber = \"\" Then GoTo Getout
    MyDrive = InputBox(\"What is the case number\", Title, \"Case Number\")
    MyDrive = \"C:\\\" & MyDrive & \"\\1\\\"
        
    If MyDrive = \"\" Then
    
    Dim AbortRetryIgnore
    
    AbortRetryIgnore = MsgBox(\"Not a valid case number - Retry or Cancel?\", vbRetryCancel + vbCritical)
        
        Select Case AbortRetryIgnore
        
        Case vbRetry
        MyDrive = InputBox(\"What is the case number\", Title, \"Case Number\")
        
        Case vbCancel
        GoTo Getout
        
        End Select
        
    
    End If
    
    If Dir(MyDrive, vbDirectory) = \"\" Then
    MsgBox \"No such Customer!\"
    GoTo Getout
    
    End If
    
    .SaveAsFile MyDrive & myJobnumber & \"-\" & myMessageItem.DisplayName
    
    End With
    
    DoEvents
    
    \'start of attachment process
    
    For Each myMessageItem In myAttachmentItems
    
    
    
    myJobnumber = InputBox(\"Title prefix?\", Title, \"99999\")
        
    If myJobnumber = \"\" Then GoTo Getout
    MyDrive = InputBox(\"What is the case number\", Title, \"Case Number\")
    MyDrive = \"C:\\\" & MyDrive & \"\\1\\\"
        
    If MyDrive = \"\" Then
    
    \'Dim AbortRetryIgnore
    
    AbortRetryIgnore = MsgBox(\"Not a valid case number - Retry or Cancel?\", vbRetryCancel + vbCritical)
        
        Select Case AbortRetryIgnore
        
        Case vbRetry
        MyDrive = InputBox(\"What is the case number\", Title, \"Case Number\")
        
        Case vbCancel
        GoTo Getout
        
        End Select
        
    \'If Dir(MyDrive, vbDirectory) = \"\" Then
    \'MkDir MyDrive
    End If
    
    \'myMessageItem.SaveAsFile MyDrive & myJobnumber & \"-\" & myMessageItem.DisplayName
    
    If Dir(MyDrive, vbDirectory) = \"\" Then
    MsgBox \"No such Customer!\"
    GoTo Getout
    
    End If
    
    myMessageItem.SaveAsFile MyDrive & myJobnumber & \"-\" & myMessageItem.DisplayName
    
    Next
    Getout:
    Set myolApp = Nothing
    Set myMessageItem = Nothing
    Set myAttachmentItems = Nothing
    End Sub
     
1 Antwort anzeigen (von insgesamt 1)
  • Sie müssen angemeldet sein, um zu diesem Thema eine Antwort verfassen zu können.