jnjustice
jnjustice

Reputation: 83

Remove Email Address from "To" field

I am trying to reply all from my group's Outlook public folder but remove the public folder email address from the reply addresses.

So far the code I have is:

Sub Reply_All_From_Folder()

    Dim original As MailItem

    Dim reply As MailItem

    Set original = ActiveInspector.CurrentItem.ReplyAll

    Set reply = Application.CreateItem(olMailItem)

    With reply

        .SentOnBehalfOfName = "[email protected]"

        .Subject = original.Subject

        .To = original.To

        .CC = original.CC

        .HTMLBody = original.HTMLBody

        .Recipients.ResolveAll

        .Display

    End With

End Sub

Upvotes: 1

Views: 1655

Answers (1)

user9167318
user9167318

Reputation:

The To and CC fields are semicolon-delimited String lists. For removing the address, you need to replace it with empty string ""

replace your

.To = original.To

with

.To = Replace(original.To, "[email protected]", "")

MSDN Link: https://msdn.microsoft.com/en-us/vba/outlook-vba/articles/mailitem-to-property-outlook

Upvotes: 1

Related Questions