logic2design
7/17/2013 - 7:33 AM

Renames the subject of the selected Outlook email

Renames the subject of the selected Outlook email

Private Sub Rename()

  'Dim olTask As Outlook.TaskItem
  'Using object so all items can be processed
  Dim olitem As Object
  Dim olExp As Outlook.Explorer
  Dim fldCurrent As Outlook.MAPIFolder
  Dim olApp As Outlook.Application
 
  
  Set olApp = Outlook.CreateObject("Outlook.Application")
  Set olExp = olApp.ActiveExplorer
  Set fldCurrent = olExp.CurrentFolder
  
  Dim cntSelection As Integer
  cntSelection = olExp.Selection.Count
  
    For i = 1 To cntSelection
    Set olitem = olExp.Selection.Item(i)
    
    ' Mark as unread
    olitem.UnRead = False
    'olitem.Sensitivity = olNormal
    olitem.Save

    newName = InputBox("Enter the revised subject:", "New Subject", olitem.Subject)
    ' OL07 uses the property .TaskSubject
    olitem.Subject = newName
    olitem.Save
    Next
    
 
 End Sub