Advertisement
Guest User

Untitled

a guest
Dec 4th, 2012
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. '
  2. ' Reply To All in Plain Text, with Internet-style ">" quoting
  3. '
  4. ' This allows you to use Outlook to reply to a mailinglist
  5. '
  6. ' Copyright 2009 Matthijs van de Water
  7. '
  8. Sub ReplyAllPlain()
  9.  
  10. Dim app As New Outlook.Application
  11. Set win = app.ActiveWindow
  12. Dim Item As Outlook.MailItem
  13.  
  14. 'Get MailItem based on EntryID, otherwise we'll get security warnings
  15. If TypeOf win Is Outlook.Explorer Then
  16. Dim strID As String
  17. Dim olNS As Outlook.NameSpace
  18. strID = win.Selection.Item(1).EntryID
  19. Set olNS = Application.GetNamespace("MAPI")
  20. Set Item = olNS.GetItemFromID(strID)
  21. Else
  22. Set Item = win.CurrentItem
  23. End If
  24.  
  25. ' Store name of the sender and date of sent message
  26. Dim name As String
  27. name = Item.SentOnBehalfOfName
  28. datestr = Format(Item.SentOn, "yyyy-MM-ddTHH:mm:ss")
  29.  
  30. ' ReplyToAll to this message in Plain formatting with > style
  31. Item.BodyFormat = olFormatPlain
  32. Item.Actions("Reply to All").ReplyStyle = olReplyTickOriginalText
  33. Dim rply As Outlook.MailItem
  34. Set rply = Item.ReplyAll
  35.  
  36. ' Rebuild original body:
  37. ' - Remove Outlook-style reply header
  38. ' - Get rid of auto-inserted signature (optionally move to end of message)
  39. orgBody = rply.Body
  40. pos = InStr(orgBody, ">") - 1
  41. sig = Left(orgBody, pos)
  42. myBody = Mid(orgBody, pos + 1)
  43. lines = Split(myBody, vbNewLine)
  44. b = False
  45. For Each myLine In lines
  46. If b Then
  47. newBody = newBody & myLine & vbNewLine
  48. End If
  49. If myLine = "> " Then
  50. b = True
  51. End If
  52. Next
  53. ' Put new body together
  54. rply.Body = "On " & datestr & ", " & name & " wrote:" _
  55. & vbNewLine & newBody & vbNewLine & sig
  56.  
  57. rply.Display
  58.  
  59. Item.Close olDiscard
  60. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement