Guest User

Untitled

a guest
May 22nd, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.82 KB | None | 0 0
  1. Private WithEvents snItems As Items
  2.  
  3. Private Sub Application_Startup()
  4. Set snItems = Session.GetDefaultFolder(olFolderSentMail).Items
  5. End Sub
  6.  
  7. Private Sub snItems_ItemAdd(ByVal item As Object)
  8. Dim CopiedItem As MailItem
  9. Dim ShareInbox As Outlook.MAPIFolder
  10. Dim MapiNameSpace As Outlook.NameSpace
  11.  
  12. If TypeName(item) = "MailItem" Then
  13.  
  14. Set MapiNameSpace = Application.GetNamespace("MAPI")
  15. Set ShareInbox = MapiNameSpace.Folders("Support").Folders("Send Mails")
  16.  
  17. If item.SenderName = "Support" Then
  18. Set CopiedItem = item.Copy
  19. CopiedItem.UnRead = True
  20. CopiedItem.Move ShareInbox
  21. End If
  22. End If
  23.  
  24. 'MsgBox "Awesome"
  25.  
  26. ExitRoutine:
  27. Set ShareInbox = Nothing
  28. Set CopiedItem = Nothing
  29. Set MapiNameSpace = Nothing
  30. End Sub
  31.  
  32. Set MapiNameSpace = Application.GetNamespace("MAPI")
  33. Set ShareInbox = MapiNameSpace.Folders("Support").Folders("Gesendete Elemente")
  34.  
  35. If item.SenderName = "Support" Then
  36. item.Move ShareInbox
  37. End If
  38.  
  39. Private Sub snItems_ItemAdd(ByVal item As Object)
  40. Dim CopiedItem As MailItem
  41. Dim ShareInbox As Outlook.MAPIFolder
  42. Dim MapiNameSpace As Outlook.NameSpace
  43.  
  44. If TypeName(item) = "MailItem" Then
  45.  
  46. Set MapiNameSpace = Application.GetNamespace("MAPI")
  47. Set ShareInbox = MapiNameSpace.Folders("Support").Folders("Send Mails")
  48.  
  49. If item.SenderName = "Support" Then
  50.  
  51. ' Turn off event handling
  52. Set snItems = Nothing
  53.  
  54. Set CopiedItem = item.Copy
  55. CopiedItem.UnRead = True
  56. CopiedItem.Move ShareInbox
  57.  
  58. ' Turn on event handling
  59. Set snItems = Session.GetDefaultFolder(olFolderSentMail).Items
  60.  
  61. End If
  62. End If
  63.  
  64. ExitRoutine:
  65. Set ShareInbox = Nothing
  66. Set CopiedItem = Nothing
  67. Set MapiNameSpace = Nothing
  68. End Sub
Add Comment
Please, Sign In to add comment