Adding sender's e-mail to global address book DL

Not open for further replies.


New Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server
Hi - I manage a DL in my company's global address book. People e-mail me to add them to the DL. Manually you can do this in the global address book by right-clicking on the DL and modifying members and adding a contact. I only have a code that can add a sender's email address (although it's taking all addresses but mine) to a group in my private contacts. Is there a way to build a code that when someone asks to be added to the DL via email I can run the macro so that it adds the sender's email (FROM field only, not TO or CC) to the global address book DL (GDL - GROUPNAME). Thanks!

The code I have been using is as follows:
Sub UpdateDistListItem()
'Create some constants
'On the next line enter the name of the list the script is to update.
'Create some variables
Dim olkItm As Object, olkRcp As Outlook.Recipient, olkLst As Outlook.DistListItem
Select Case TypeName(Application.ActiveWindow)
Case "Explorer"
Set olkItm = Application.ActiveExplorer.Selection(1)
Case "Inspector"
Set olkItm = Application.ActiveInspector.CurrentItem
End Select
If TypeName(olkItm) <> "Nothing" Then
Select Case olkItm.Class
'If the source item is an email or appointment
Case olMail, olAppointment
'Find the distribution list to update
Set olkLst = Session.GetDefaultFolder(olFolderContacts).Items.Find("[Name] = '" & LIST_NAME & "'")
If TypeName(olkLst) = "Nothing" Then
MsgBox "I could not find a distribution list named '" & LIST_NAME & "'.", vbCritical + vbOKOnly, "Operation Cancelled "
With olkLst
'If the source item is an email, then add the sender
If olkItm.Class = olMail Then
Set olkRcp = Session.CreateRecipient(olkItm.SenderEmailAddress)
.AddMember olkRcp
End If
'Loop through the recipients of the source item
For Each olkRcp In olkItm.Recipients
'If the recipient is not the current user
If olkRcp.Name <> Session.CurrentUser.Name Then
'If the source item an email or if it is an appointment and the recipient is not a resource
If (olkItm.Class = olMail) Or (olkItm.Class = olAppointment And olkRcp.Type <> olResource) Then
'Add the recipient to the list
.AddMember olkRcp
End If
End If
End With
End If
End Select
End If
Set olkItm = Nothing
Set olkRcp = Nothing
Set olkLst = Nothing
End Sub
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
P MS OUTLOOK 2013 - Adding Sender on the CC line Using Outlook 5
G Adding a contact to a specific folder Using Outlook 0
S Adding a recipient's column to Sent folder in Outlook 2010 Outlook VBA and Custom Forms 1
R Adding Userform Dropdown List items from names of subfolders on network drive Outlook VBA and Custom Forms 10
G Stop Outlook 365 adding meetings to calendar Using Outlook 2
G Removing old emails when adding accounts Using Outlook 3
D Contact Group - Adding Bulk Addresses Using Outlook 2
C Outlook 2007 Removing then adding account restores junk email processing Using Outlook 0
J O365 - Adding Shared Google Calendar ICS link issue in O365 Using Outlook 0
B Adding signature to bottom of VBA reply email Outlook VBA and Custom Forms 1
S User Defined Fields adding new value (2) Using Outlook 0
M Changing the preferred order for "Put this entry in" list for adding new contacts to the Address Book Using Outlook 1
M Adding Subject to this Link-Saving VBA Outlook VBA and Custom Forms 5
E Project Management - Adding Folders for Different Folder Types Using accounts in Outlook 0
D Adding Enterprise Exchange Email Account to Outlook Prevents Sending via Account Using accounts in Outlook 10
S Adding new Exchange (2016) rule very slow down Microsoft Outlook Exchange Server Administration 0
Z Outlook Custom Form: Adding Dropdown(Project Code) at the end of subject Outlook VBA and Custom Forms 0
Z Adding dropdown list using custom form Outlook VBA and Custom Forms 7
M Adding Macro to populate "to" "subject" "body" not deleting email string below. Outlook VBA and Custom Forms 5
E Unable to open Outlook 2010 after adding new email account Using Outlook 4
O Adding a new account - "CompanyL (none)" line is added Using Outlook 5
broadbander Needing help with reply/reply all while keeping attachments and adding a new CC recipient. Outlook VBA and Custom Forms 5
M adding corresponding contact form data on a mass scale Using Outlook 5
A VB to "reply all" email items stored in a folder of outlook with adding a new message Outlook VBA and Custom Forms 0
K adding more rules to 'different domains check' macro Outlook VBA and Custom Forms 2
R User Defined Fields adding new value Using Outlook 3
W Adding A Macro To Message Ribbon Outlook VBA and Custom Forms 2
I Collecting mail address from GAB and adding to Outlook Task Using Outlook 2
A Outlook 2016 - adding account creates a new/strange address Using accounts in Outlook 18
F Adding textbox filter to listbox? Outlook VBA and Custom Forms 2
N Recurring invite sent w/distribution list adding/removing attendees Using Outlook 0
J Issues with adding iCloud to Outlook Using Outlook 1
G Adding a contact to Outlook with a custom form using Access VBA Outlook VBA and Custom Forms 1
C Macro to send email after changing from address and adding signature Outlook VBA and Custom Forms 1
J Adding Reply & Delete to main toolbar? Using Outlook 0
T Outlook 2007 adding categories Using Outlook 15
N Adding Appointment Item in Outlook to Shared Calendar Folder Outlook VBA and Custom Forms 7
Diane Poremsky Adding Emojis to Outlook's AutoCorrect Using Outlook 0
T Adding "Mark As Complete" btton to Task Remindet Pop-Up Using Outlook 3
O Saving Attachments to folder on disk and adding Initials to end of file name Outlook VBA and Custom Forms 9
Ascar_CT Adding contacts on Android phone and then syncing them to Outlook Using accounts in Outlook 4
A Adding a 2010 sharepoint contact list to outlook 2010 address book Using Outlook 1
M Adding fields to Task in Outlook Home and Business 2010 Outlook VBA and Custom Forms 7
S Using Send on Behalf is adding extra data in from line Using Outlook 1
Lucylou Outlook 2013 Adding breaks profile, "Outlook not working" messag Using accounts in Outlook 1
C Adding Categories when Composing Email Using Outlook 1
stephenjones Adding a business account to Outlook Using Outlook 1
Chris Grew Adding 2nd Email Address BCM (Business Contact Manager) 3
G Adding an attachment to email I just created (VBA) Outlook VBA and Custom Forms 1
tswatek Inbox problems after adding MS Exchange email Using Outlook 2

Similar threads