VBA zum automatischen Speichern von Mails

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

1 Antwort anzeigen (von insgesamt 1)
  • Autor
    Beitrag
  • #130434
    Teqi
    Participant

      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]

    1 Antwort anzeigen (von insgesamt 1)

    Hat Ihnen der Beitrag gefallen?

    1 Stern2 Sterne3 Sterne4 Sterne5 Sterne (Keine Bewertung vorhanden)
    Loading...