VBA zum automatischen Speichern von Mails

Home-›Foren-›Outlook-›Outlook VBA-›VBA zum automatischen Speichern von Mails

2 Antworten anzeigen - 1 bis 2 (von insgesamt 2)
  • Autor
    Beitrag
  • #36183
    Unbekannt
    Teilnehmer

      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

      #130434
      Teqi
      Teilnehmer

        das habe ich gefunden (vielleicht hilft es):
        Hier mal ein Vorschlag:

        [code]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
        [/code]

      2 Antworten anzeigen - 1 bis 2 (von insgesamt 2)

      -