Hi Guys

I'm trying to write a macro to rename multiple emails that have been highlighted in the folder view.

The below code is what I've come up with so far, although it only seems to rename the first email. The code pops up an alert box to ask what you would like the emails to be renamed to.

The wierd thing is that if I try to change another setting like msn.unread = true then it works for all the emails. Also adding an alert to show which email is the current email in the loop also shows that it is stepping through each email.

Can anyone advise what I need to change in order to set the subject for each email selected.

[vba]
Sub renameEmails()
On Error Resume Next
Dim MsgColl As Object
Dim msg As Outlook.MailItem
Dim objNS As Outlook.NameSpace
Dim i As Long
Dim subjectname As String

Select Case TypeName(Application.ActiveWindow)
Case "Explorer"
' a collection of selected items
Set MsgColl = ActiveExplorer.Selection
Case "Inspector"
' only one item was selected
Set msg = ActiveInspector.CurrentItem
End Select
On Error GoTo 0

If (MsgColl Is Nothing) And (msg Is Nothing) Then
GoTo ExitProc
End If
subjectname = InputBox("Enter Subject Name", "Subject?")
If Not MsgColl Is Nothing Then
For i = 1 To MsgColl.Count
' set an obj reference to each mail item so we can move it
Set msg = MsgColl.Item(i)
With msg
.subject = subjectname
End With
Next i
ElseIf Not msg Is Nothing Then
msg.subject = subjectname
End If
ExitProc:
Set msg = Nothing
Set MsgColl = Nothing
Set olMyFldr = Nothing
Set objNS = Nothing
End Sub
[/vba]