ich benötige ein Makro, welches die Dateianhänge aus markierten E-Mails im Outlook auf einmal auf einen hinterlegten Pfad speichert. Ich habe leider keine Erfahrung im Bereich VB-Programmierung.. vielleicht kann hier jemand helfen?
Vielen Dank!
Sub SavePGPOnHarddrive()
Dim myAttachments As Outlook.Attachments
Dim olMailItem As Outlook.MailItem
Dim lngAttachCount As Long
Dim strAttach As String
Dim strPath As String
' Pfad angeben
strPath = Environ("USERPROFILE") & "\Desktop\PGPFiles\"
' Aktive Mail setzen
Select Case True
Case TypeOf Application.ActiveWindow Is Outlook.Inspector
Set olMailItem = Application.ActiveInspector.CurrentItem
Case Else
With Application.ActiveExplorer.Selection
If .Count Then Set olMailItem = .Item(1)
End With
If olMailItem Is Nothing Then Exit Sub
End Select
' Anhangobjekt erstellen
Set myAttachments = olMailItem.Attachments
' Anhänge prüfen und speichern. Nur Dateien vom Typ PGP wird gespeichert
If myAttachments.Count > 0 Then
For lngAttachCount = myAttachments.Count To 1 Step -1
If Right(myAttachments(lngAttachCount).DisplayName, 3) = "pgp" Then
.Attachments.Item(i).SaveAsFile strPath & _
.Attachments.Item(lngAttachCount).Filename
End If
Next lngAttachCount
End Sub
VBA/HTML-CodeConverter, AddIn für Office 2002-2016 - in VBA geschrieben von Lukas Mosimann. Projektbetreuung:René Holtz
Code erstellt und getestet in Office 16 - mit VBAHTML 12.6.0
Sub SavePGPOnHarddrive()
Dim myAttachments As Outlook.Attachments
Dim olMailItem As Outlook.MailItem
Dim lngAttachCount As Long
Dim strAttach As String
Dim strPath As String
' Pfad angeben
strPath = Environ("USERPROFILE") & "\Desktop\PGPFiles\"
' Aktive Mail setzen
Select Case True
Case TypeOf Application.ActiveWindow Is Outlook.Inspector
Set olMailItem = Application.ActiveInspector.CurrentItem
Case Else
With Application.ActiveExplorer.Selection
If .Count Then Set olMailItem = .Item(1)
End With
If olMailItem Is Nothing Then Exit Sub
End Select
' Anhangobjekt erstellen
Set myAttachments = olMailItem.Attachments
' Anhänge prüfen und speichern. Nur Dateien vom Typ PGP wird gespeichert
If myAttachments.Count > 0 Then
For lngAttachCount = myAttachments.Count To 1 Step -1
If Right(myAttachments(lngAttachCount).DisplayName, 3) = "pgp" Then
olMailItem.Attachments.Item(i).SaveAsFile strPath & _
olMailItem.Attachments.Item(lngAttachCount).Filename
End If
Next lngAttachCount
End If
End Sub
VBA/HTML-CodeConverter, AddIn für Office 2002-2016 - in VBA geschrieben von Lukas Mosimann. Projektbetreuung:René Holtz
Code erstellt und getestet in Office 16 - mit VBAHTML 12.6.0
Die erweiterte Suchfunktion hilft dir, gezielt die besten Antworten zu finden
Suche nach den besten AntwortenEntdecke unsere meistgeklickten Beiträge in der Google Suche
Top 100 Threads jetzt ansehen