Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6246513
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T12:42:16+00:00 2026-05-24T12:42:16+00:00

I sort recipients when composing an email. If I have 3 recipients (for example),

  • 0

I sort recipients when composing an email.

If I have 3 recipients (for example), run the sort macro, and then remove a recipient from the To: text box, running the macro a second time causes the removed recipient to re-appear. When I step through the macro on the second run, I can see that both .CurrentItem.To and the Recipients object still have all 3 recipients.

It is intermittent. Is there any way to force the Recipients object to update when the To: text box has been edited?

I can’t find anything in the Outlook VBA documentation and trial and error has proved fruitless.

Code excerpt:

Public Sub SortRecipients()
    With Application.ActiveInspector
        If TypeOf .CurrentItem Is Outlook.MailItem Then
            Debug.Print "Before: "
            Debug.Print "To: " & .CurrentItem.To
            Debug.Print "# of recipients: " & .CurrentItem.Recipients.Count

            ' Force an update if recipients have changed (DOESN'T HELP)
            .CurrentItem.Recipients.ResolveAll

            Set myRecipients = .CurrentItem.Recipients
            ' Create objects for To list
            Dim myRecipient As recipient
            Dim recipientToList As Object
            Set recipientToList = CreateObject("System.Collections.ArrayList")

            ' Create new lists from To line
            For Each myRecipient In myRecipients
                    recipientToList.Add myRecipient.Name
            Next

            ' Sort the recipient lists
            recipientToList.Sort
            ' Remove all recipients so we can re-add in the correct order
            While myRecipients.Count > 0
                myRecipients.Remove 1
            Wend

            ' Create new To line
            Dim recipientName As Variant
            For Each recipientName In recipientToList
                myRecipients.Add (recipientName)
            Next recipientName
            .CurrentItem.Recipients.ResolveAll

        End If
    End With
End Sub

Steps to reproduce:

  1. Add 4 recipients to the “To” line of a new email in Outlook 2007 (click “Check Names” to resolve the addresses.)
  2. Run the SortRecipients macro. (Recipients are now sorted)
  3. Delete one recipient, re-run the SortRecipients macro.
  4. After doing this, I still have 4 recipients (the deleted one returns).
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T12:42:16+00:00Added an answer on May 24, 2026 at 12:42 pm

    You can (and should) add an Option Explicit, Outlook would have told you that myRecipients was not declared at the begining of your code.

    I added:

    Dim myRecipients As Recipients
    

    [EDIT] That wasn’t enough to get the To field refreshed. I tried several things but eventually, i added a .CurrentItem.Save instead of your try of .CurrentItem.Recipients.ResolveAll

    I think i made it work this way on my Outlook 2007.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I often have to sort a dictionary (consisting of keys & values) by value.
I am trying to send an email via Outlook from within a VB6 program.
Sort of the reverse of finding duplicate rows. I have a table with a
Sort of a continuation from an earlier question, done a bunch of googling, but
Sort of how this website shows a bar on top when you have new
I have a bit of a problem i am trying to sort out. I
Sort of a simple question. I have a tableview in a navigationcontroller. When I
The sort command lets me put lines in alphabetical order and remove duplicate lines.
sort provides two kinds of numeric sort. This is from the man page: -g,
I have GetConversationPaged sp that selects paged data from table called user_messages_index and includes

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.