Advertisement
Guest User

Untitled

a guest
May 26th, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. Dim rng As Range
  2. Dim olApp As Outlook.Application
  3. Dim objNS As Outlook.Namespace
  4. Dim olFolder As Outlook.MAPIFolder
  5. Dim msg As Outlook.MailItem
  6. Dim cell As Range
  7. Dim countE As Integer
  8. Dim start As Range
  9. Dim finish As Range
  10. Dim movetomanger As Outlook.MAPIFolder
  11. Dim countM As Integer
  12. Dim rngarry As Variant
  13. Dim emcount, casecount, movedcount, itm
  14. Set rng = Range(Range("A2"), Range("A2").End(xlDown))
  15. Set olApp = Outlook.Application
  16. Set objNS = olApp.GetNamespace("MAPI")
  17. Set olFolder = objNS.Folders("Documents").Folders("Inbox")
  18.  
  19. Set movetomanger = olFolder.Folders("......Managers").Folders(".managersname")
  20.  
  21. Set finish = ThisWorkbook.Sheets("Mover").Range("I11")
  22. Set start = ThisWorkbook.Sheets("Mover").Range("I10")
  23. start.Value = Format(Now, "hh:mm:ss")
  24.  
  25. Set emcount = Range("I12")
  26. Set casecount = Range("I13")
  27. Set movedcount = Range("I14")
  28. OptimizeCode_Begin
  29. countM = 0
  30. countE = 0
  31.  
  32. rngarry = Range("a2:A241").Value
  33.  
  34.  
  35. For Each msg In olFolder.Items
  36. For Each itm In rngarry
  37. If (itm = msg.EntryID) Then
  38. msg.UnRead = True
  39.  
  40. msg.move managersname
  41. countM = 1 + countM
  42.  
  43. End If
  44. Next
  45. countE = 1 + countE
  46. Next
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53. finish.Value = Format(Now, "hh:mm:ss")
  54. OptimizeCode_End
  55. emcount.Value = countE
  56. casecount.Value = rng.count
  57. movedcount.Value = countM
  58.  
  59.  
  60. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement