Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

Outlook Macro to place prefix on selected email subjects?

I have been trying to write a macro to bulk edit multiple email subject lines in Outlook. I want to be able to select multiple emails in outlook and run the macro, which put a prefix at the start of the subject line of all selected emails. The prefix will be determined by a pop-up box with a list of options, populated from a .txt file.

Currently I have the following code written:

Public lstText As String

Public OpenEdit As String

Public MType As String

Public Sub SetSubject()

Dim aItem As Object

 OpenEdit = ""


Set aItem = GetCurrentItem()

aItem.Subject = lstText & " " & aItem.Subject

If MType = "Inspector" Then aItem.Save

If OpenEdit = "Edit" Then

If MType = "Explorer" Then aItem.Display

End If

Set aItem = Nothing

End Sub

Function GetCurrentItem() As Object

    Dim objApp As Outlook.Application

    Set objApp = Application

    On Error Resume Next

    Select Case TypeName(objApp.ActiveWindow)

        Case "Explorer"

            Set GetCurrentItem = objApp.ActiveExplorer.Selection.Item(1)

            MType = "Explorer"

        Case "Inspector"

            Set GetCurrentItem = objApp.ActiveInspector.CurrentItem

            MType = "Inspector"

    End Select

    Set objApp = Nothing

End Function

With the current code, the macro will only work on a single email when that email is open in a window. What do I need to edit so that this will work on multiple selected emails, applying the same selected prefix to all in the current selection?

There are no answers yet.
Be the first to answer this question.