Hi all,
I'm still working my way through Macros and although Excel brought me here originally, I'm branching out in to other MS programs.
My current project is a Macro that edits the subject line of selected emails. The background is that a number of users all work out of a shared mailbox, and when an email is actioned, the user is required to add their initials to the end of the subject before filing it in the relevant mailbox.
I Googled the majority of the below and I'm finding that although it correctly edits the email title by appending " - JC" to the end of the subject, it only does so for the first email that is selected.
When I step through the Macro, I can see that it loops the correct number of times based on the number of emails highlighted but I cannot understand why it only updates the first email in the selection.
Any help would be much appreciated.
Thanks in advance.
I'm still working my way through Macros and although Excel brought me here originally, I'm branching out in to other MS programs.
My current project is a Macro that edits the subject line of selected emails. The background is that a number of users all work out of a shared mailbox, and when an email is actioned, the user is required to add their initials to the end of the subject before filing it in the relevant mailbox.
I Googled the majority of the below and I'm finding that although it correctly edits the email title by appending " - JC" to the end of the subject, it only does so for the first email that is selected.
When I step through the Macro, I can see that it loops the correct number of times based on the number of emails highlighted but I cannot understand why it only updates the first email in the selection.
Code:
Public Sub InitialEmail()
Dim currentExplorer As Explorer
Dim Selection As Selection
Dim obj As MailItem
Set currentExplorer = Application.ActiveExplorer
Set Selection = currentExplorer.Selection
For Each obj In Selection
With obj
.Subject = obj.Subject & " - JC"
End With
Next
End Sub
Any help would be much appreciated.
Thanks in advance.