lamensterms
06-05-2015, 12:42 AM
Hi guys,
Just wondering if I could please have some assistance tweaking a bit of code I found here... http://www.vbaexpress.com/forum/showthread.php?52447-Change-Subject-on-Outlook-Mail-and-Forward
The intent is to be able to select a bunch of emails (in inbox) and insert a prefix into the subject line.
Sub Test()
Dim olMsg As MailItem
On Error Resume Next
Set olMsg = ActiveExplorer.Selection.Item(1)
Dim Subject As String
Dim Subjectn As String
Subject = olMsg.Subject
Subjectn = "3322 - " + Subject
olMsg.Subject = Subjectn
lbl_Exit:
Set olMsg = Nothing
Exit Sub
End Sub
... is what I've got so far. It works, but only on 1 of the selected emails. Set olMsg = ActiveExplorer.Selection.Item(1) is the line that I think I need to change, but I'm afraid I don't know what to change it to (or if there is a better way to achieve my goal?).
Thanks a lot for any help.
Just wondering if I could please have some assistance tweaking a bit of code I found here... http://www.vbaexpress.com/forum/showthread.php?52447-Change-Subject-on-Outlook-Mail-and-Forward
The intent is to be able to select a bunch of emails (in inbox) and insert a prefix into the subject line.
Sub Test()
Dim olMsg As MailItem
On Error Resume Next
Set olMsg = ActiveExplorer.Selection.Item(1)
Dim Subject As String
Dim Subjectn As String
Subject = olMsg.Subject
Subjectn = "3322 - " + Subject
olMsg.Subject = Subjectn
lbl_Exit:
Set olMsg = Nothing
Exit Sub
End Sub
... is what I've got so far. It works, but only on 1 of the selected emails. Set olMsg = ActiveExplorer.Selection.Item(1) is the line that I think I need to change, but I'm afraid I don't know what to change it to (or if there is a better way to achieve my goal?).
Thanks a lot for any help.