Advertisement
Guest User

Untitled

a guest
Mar 31st, 2015
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. Public WithEvents myOlApp As Outlook.Application
  2.  
  3. Public Sub Initialize_handler()
  4. Set myOlApp = Outlook.Application
  5. End Sub
  6.  
  7. Private Sub myOlApp_ItemSend(ByVal Item As Object, Cancel As Boolean)
  8. Dim prompt As String
  9. prompt = "Are you sure you want to send " & Item.Subject & "?"
  10. If MsgBox(prompt, vbYesNo + vbQuestion, "Sample") = vbNo Then
  11. Cancel = True
  12. End If
  13. End Sub
  14.  
  15. Sub SaveAllAttachments(objitem As MailItem)
  16.  
  17. Dim objAttachments As Outlook.Attachments
  18. Dim strName, strLocation As String
  19. Dim dblCount, dblLoop As Double
  20.  
  21. Dim strSub As String
  22. Dim iRcpCount, iRcp As Integer
  23.  
  24. strLocation = "O:PDF"
  25.  
  26. On Error GoTo ExitSub
  27. If objitem.Class = olMail Then
  28. Set objAttachments = objitem.Attachments
  29. dblCount = objAttachments.Count
  30. If dblCount <= 0 Then
  31. GoTo 100
  32. End If
  33.  
  34. strSub = ""
  35. iRcpCount = objitem.Recipients.Count
  36. For iRcp = 1 To iRcpCount
  37. If objitem.Recipients(iRcp).Name = "Postlist1" Then
  38. strSub = "Folder1onOdrive"
  39. ElseIf objitem.Recipients(iRcp).Name = "Postlist2" Then
  40. strSub = "Folder2onOdrive"
  41. ElseIf objitem.Recipients(iRcp).Name = "Postlist3" Then
  42. strSub = "Folder3onOdrive"
  43. End If
  44.  
  45. Next iRcp
  46.  
  47. For dblLoop = 1 To dblCount
  48. strName = objAttachments.Item(dblLoop).FileName
  49. 'strName = strLocation & strName
  50. strName = strLocation & strSub & strName
  51. 'strName = strLocation & strName
  52. objAttachments.Item(dblLoop).SaveAsFile strName
  53. Next dblLoop
  54. objitem.Delete
  55. End If
  56. 100
  57. ExitSub:
  58. Set objAttachments = Nothing
  59. Set objOutlook = Nothing
  60. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement