Convert Distribution List of Contacts to Single Contacts

Status
Not open for further replies.

LMS

Senior Member
Outlook version
Outlook 2007
Email Account
Exchange Server
I read the following to simply select a distribution list I received, and then run this macro that creates a contact for each one in the distribution list.....but it saves all the contacts to the Contact folder...so can I change it to save them to a subfolder under the Contact folder?

Sub CreateContactsfromDL()

Dim o_list As Object

Dim objContact As outlook.contactItem

' set your category here.

t_cat = "From DL"

' Current object and should be the distributionlist

Set o_list = GetCurrentItem()

For i = 1 To o_list.MemberCount

' Create separate contacts

Set objContact = Application.CreateItem(olContactItem)

With objContact
.Email1Address = o_list.GetMember(i).Address
.FullName = o_list.GetMember(i)
.Categories = t_cat
.Save

End With

Next

Set objContact = Nothing

Set o_list = 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)
Case "Inspector"
Set GetCurrentItem = objApp.ActiveInspector.currentItem
End Select

Set objApp = Nothing

End Function
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
This line: Set objContact = Application.CreateItem(olContactItem) uses the default folder. You need to set the folder then use .Add to add to that folder.

Replace the set objcontact line in your code with the two Set lines below and the dim at the top of the macro.

Dim Items As Outlook.Items

Set Items = Session.GetDefaultFolder(olFolderContacts).Folders("subfolder").Items

Set objContact = Items.Add(olContactItem)

- - - Updated - - -

This line: Set objContact = Application.CreateItem(olContactItem) uses the default folder. You need to set the folder then use .Add to add to that folder.






Replace the set objcontact line in your code with the two Set lines below and the dim at the top of the macro.




Dim Items As Outlook.Items




Set Items = Session.GetDefaultFolder(olFolderContacts).Folders("subfolder").Items


Set objContact = Items.Add(olContactItem)
 

LMS

Senior Member
Outlook version
Outlook 2007
Email Account
Exchange Server
Thanks much as usual....it worked when I used a distribution list of 5 emails....but when I used for a distribution list of 400 emails, it only creates one contact which is the first contact in the distribution list....anything to change please?
 

Forum Admin

Senior Member
The number of members shouldn't matter - 5 or 400. It sounds like its erroring and exiting. Try commenting out the on error resume next line in the function and see what happens.
 

LMS

Senior Member
Outlook version
Outlook 2007
Email Account
Exchange Server
How do I do what you said to do...as I don't know what this means: Try commenting out the on error resume next line in the function and see what happens
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
change

On Error Resume Next
to
' On Error Resume Next

to comment it out. This will prevent the macro from going to the next line when it hits an error. Because its in the function, it may not show what line its exiting on, but it should stop, so we'll know there is a problem.

- - - Updated - - -

change


On Error Resume Next



to



' On Error Resume Next




to comment it out. This will prevent the macro from going to the next line when it hits an error. Because its in the function, it may not show what line its exiting on, but it should stop, so we'll know there is a problem.
 

LMS

Senior Member
Outlook version
Outlook 2007
Email Account
Exchange Server
I did it and no error shows up and nothing is colored
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
K Need to convert .mmf file to .pst format Outlook VBA and Custom Forms 4
T Why does outlook 2010 convert only some forum notifications to plain text? Using Outlook 0
B VBA to convert email to task, insert text of email in task notes, and attach copy of original email Outlook VBA and Custom Forms 4
M Convert Subject Line to Internet Header version of Subject Outlook VBA and Custom Forms 10
E To convert imported data to custom fields in Task list Outlook VBA and Custom Forms 1
P How do I convert outlook “to-do” items to “tasks” Outlook VBA and Custom Forms 1
I Convert POP3 account (PST) to IMAP (.OST) Using Outlook 3
S problem with convert Using Outlook 1
I Outlook 2016 64bit - on receipt convert emails into PDF and save Outlook VBA and Custom Forms 2
C convert an .ost to .pst Using Outlook 3
D The way to convert ost to pst Using Outlook 2
J Outlook 2013 how to convert 2013 OST file into an another format, i m using outlook 2013 versions. Using Outlook 1
sneaky30 convert text to date Outlook VBA and Custom Forms 1
P Is it possible to convert address book to "Auto-Complete List" (NK2)? Using Outlook 5
Diane Poremsky Convert an Offline File (.ost) to a Personal File (.pst) New Slipstick.com Articles 0
S How to do I convert OST file to PST? Exchange Server Administration 3
J convert .pst to .eml, how is it possible? Using Outlook 1
M convert/import a customized record into the default "Account" record BCM (Business Contact Manager) 0
V Check/convert to emailaddresses Outlook VBA and Custom Forms 11
R Convert Access table to pst Using Outlook 1
M Outlook 2013 won't convert Excel contacts into Outlook contacts using my custom form Using Outlook 3
G Is there any way to convert outlook 2003 to outlook 2007 Using Outlook 5
D Outlook contacts no in address book - 2002 pst file convert to 2007 pst file? Using Outlook 0
P Outlook 2002 - How to upgrade to 2003 and convert PST from ANSI to Unicode? Using Outlook 7
A Outlook 2003: convert all RTF emails to HTML Outlook VBA and Custom Forms 1
J How to convert BCM contacts to normal Outlook contacts BUT... BCM (Business Contact Manager) 2
G Tasks - convert email to task & attach email Outlook VBA and Custom Forms 6
A Re: Convert Oportunity to Project? BCM (Business Contact Manager) 3
B convert VBA code to Add-in Outlook VBA and Custom Forms 1
Q How tough is it to convert VBA to Addin Outlook VBA and Custom Forms 1
M How can we find the list of users who are members of a deleted distribution list? Exchange Server Administration 2
Healy Consultants Macro to remove inside organization distribution list email address when reply to all recepients Outlook VBA and Custom Forms 0
M Auto expand Distribution List Before Sending Email Outlook VBA and Custom Forms 1
E Distribution lists Using Outlook 1
M Question about nested distribution lists Outlook VBA and Custom Forms 3
G Bcc help - Preventing multiple forwards from a bcc'd distribution group Using Outlook 1
A Are categories still recommended for creating local distribution lists? Using Outlook 3
Diane Poremsky Using Categories for Dynamic Distribution Lists New Slipstick.com Articles 0
N Recurring invite sent w/distribution list adding/removing attendees Using Outlook 0
D Macro to scan email distribution list when replying Using Outlook 2
Diane Poremsky Find the Distribution Lists a Contact Belongs to New Slipstick.com Articles 0
T Missing sub-contact folders (distribution lists) Using Outlook 3
J Maintain Distribution List Using Outlook 3
S Finding Distribution List Name Outlook VBA and Custom Forms 3
J Outlook 2013 - Exchange 2007 manage distribution group Exchange Server Administration 1
K Rule for Distribution List Using Outlook 0
M add contacts to shared contacts distribution list Using Outlook 1
M Nested distribution lists: how to count UNIQUE # of people... Outlook VBA and Custom Forms 13
M VBA script to allow mail merges of distribution groups? Using Outlook 7
E Add sender to distribution list? Using Outlook 3

Similar threads

Top