Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public WithEvents myOlApp As Outlook.Application
- Public Sub Initialize_handler()
- Set myOlApp = Outlook.Application
- End Sub
- Private Sub myOlApp_ItemSend(ByVal Item As Object, Cancel As Boolean)
- Dim prompt As String
- prompt = "Are you sure you want to send " & Item.Subject & "?"
- If MsgBox(prompt, vbYesNo + vbQuestion, "Sample") = vbNo Then
- Cancel = True
- End If
- End Sub
- Sub SaveAllAttachments(objitem As MailItem)
- Dim objAttachments As Outlook.Attachments
- Dim strName, strLocation As String
- Dim dblCount, dblLoop As Double
- Dim strSub As String
- Dim iRcpCount, iRcp As Integer
- strLocation = "O:PDF"
- On Error GoTo ExitSub
- If objitem.Class = olMail Then
- Set objAttachments = objitem.Attachments
- dblCount = objAttachments.Count
- If dblCount <= 0 Then
- GoTo 100
- End If
- strSub = ""
- iRcpCount = objitem.Recipients.Count
- For iRcp = 1 To iRcpCount
- If objitem.Recipients(iRcp).Name = "Postlist1" Then
- strSub = "Folder1onOdrive"
- ElseIf objitem.Recipients(iRcp).Name = "Postlist2" Then
- strSub = "Folder2onOdrive"
- ElseIf objitem.Recipients(iRcp).Name = "Postlist3" Then
- strSub = "Folder3onOdrive"
- End If
- Next iRcp
- For dblLoop = 1 To dblCount
- strName = objAttachments.Item(dblLoop).FileName
- 'strName = strLocation & strName
- strName = strLocation & strSub & strName
- 'strName = strLocation & strName
- objAttachments.Item(dblLoop).SaveAsFile strName
- Next dblLoop
- objitem.Delete
- End If
- 100
- ExitSub:
- Set objAttachments = Nothing
- Set objOutlook = Nothing
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement