PC Review


Reply
Thread Tools Rate Thread

add to existing distribution list

 
 
barret bonden
Guest
Posts: n/a
 
      5th Jan 2010
Trying to add to an existing distribution list; (from MS Access to Outlook
2003) ; code below can add, but always creates new DL (see below); skipping
through Access records into general top level contacts was easy, DL work has
been very frustrating.
Code below works (it adds to a list) but it needs to refer to a known list.
How do I do this successfully ?
I've played with :
objDistList =
myFolder.Items.Add(Outlook.OlItemType.olDistributionListItem)
in other code but get "object variable not set" even though I can see it has
been !



Dim objOutlook As New Outlook.Application
Dim objNameSpace As Outlook.NameSpace
Dim objDistList As Outlook.DistListItem
Dim objMail As Outlook.MailItem
Dim objRecipients As Outlook.Recipients


Set objNameSpace = objOutlook.GetNamespace("MAPI")
Set objDistList = objOutlook.CreateItem(olDistributionListItem)
Set objMail = objOutlook.CreateItem(olMailItem)
Set objRecipients = objMail.Recipients
objDistList.DLName = InputBox("Enter name of Distribution List")
'objDistList.DLName = "test"



'For i = 1 To Cells(ActiveSheet.Rows.Count, 1).End(xlUp).Row
'objRecipients.Add (Range("C" & i).Value)
'Next i


objRecipients.Add "(E-Mail Removed)"
objRecipients.Add "(E-Mail Removed)"


objDistList.AddMembers objRecipients
'objDistList.Display
objDistList.Save
objRecipients.ResolveAll

Set objOutlook = Nothing
Set objNameSpace = Nothing
Set objDistList = Nothing
Set objMail = Nothing
Set objRecipients = Nothing




 
Reply With Quote
 
 
 
 
Sue Mosher [MVP]
Guest
Posts: n/a
 
      5th Jan 2010
You need to use the MAPIFolder.Items.Find method to return the existing list
based on a query against some known criteria, such as the Subject (i.e. list
name).
--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


"barret bonden" <(E-Mail Removed)> wrote in message
news:4b43a762$0$31272$(E-Mail Removed)...
> Trying to add to an existing distribution list; (from MS Access to Outlook
> 2003) ; code below can add, but always creates new DL (see below);
> skipping through Access records into general top level contacts was easy,
> DL work has been very frustrating.
> Code below works (it adds to a list) but it needs to refer to a known
> list. How do I do this successfully ?



 
Reply With Quote
 
barret bonden
Guest
Posts: n/a
 
      5th Jan 2010

Ahhhh ! (sigh of relief) the guardian angel of Outlook programmers is
still there. Ms. Mosher, I've been professionally programming in VB/VBA for
16 + (?) years now , but still can't make substantial heads or tails of
Outlook syntax; I have no real capacity to be creative here.

This is crass of me, but could you be more explicit ? Or direct me to some
code (been looking for weeks) that solves this ?




"Sue Mosher [MVP]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> You need to use the MAPIFolder.Items.Find method to return the existing
> list based on a query against some known criteria, such as the Subject
> (i.e. list name).
> --
> Sue Mosher, Outlook MVP
> Author of Microsoft Outlook 2007 Programming:
> Jumpstart for Power Users and Administrators
> http://www.outlookcode.com/article.aspx?id=54
>
>
> "barret bonden" <(E-Mail Removed)> wrote in message
> news:4b43a762$0$31272$(E-Mail Removed)...
>> Trying to add to an existing distribution list; (from MS Access to
>> Outlook 2003) ; code below can add, but always creates new DL (see
>> below); skipping through Access records into general top level contacts
>> was easy, DL work has been very frustrating.
>> Code below works (it adds to a list) but it needs to refer to a known
>> list. How do I do this successfully ?

>
>



 
Reply With Quote
 
Sue Mosher [MVP]
Guest
Posts: n/a
 
      6th Jan 2010
There's nothing special about Outlook syntax. It's all objects, properties,
methods, and events, the same as with other libraries you may have used in
VB/VBA. The method you need, Items.Find, is well documented in Outlook VBA
Help and in the Outlook Developer Reference on MSDN.
--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


"barret bonden" <(E-Mail Removed)> wrote in message
news:4b43bf48$0$5015$(E-Mail Removed)...
>
> Ahhhh ! (sigh of relief) the guardian angel of Outlook programmers is
> still there. Ms. Mosher, I've been professionally programming in VB/VBA
> for
> 16 + (?) years now , but still can't make substantial heads or tails of
> Outlook syntax; I have no real capacity to be creative here.
>
> This is crass of me, but could you be more explicit ? Or direct me to
> some
> code (been looking for weeks) that solves this ?
>
>
>
>
> "Sue Mosher [MVP]" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> You need to use the MAPIFolder.Items.Find method to return the existing
>> list based on a query against some known criteria, such as the Subject
>> (i.e. list name).
>>
>> "barret bonden" <(E-Mail Removed)> wrote in message
>> news:4b43a762$0$31272$(E-Mail Removed)...
>>> Trying to add to an existing distribution list; (from MS Access to
>>> Outlook 2003) ; code below can add, but always creates new DL (see
>>> below); skipping through Access records into general top level contacts
>>> was easy, DL work has been very frustrating.
>>> Code below works (it adds to a list) but it needs to refer to a known
>>> list. How do I do this successfully ?

>>
>>

>
>




 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I add and existing contact to an existing Distribution list? Octavio Microsoft Outlook Contacts 1 24th Jan 2009 08:10 PM
Re: How do I add and existing contact to an existing Distribution list? Russ Valentine [MVP-Outlook] Microsoft Outlook Contacts 1 24th Jan 2009 06:00 PM
How do I add an existing contact to my existing Distribution List wihout having to open the Distribution List? Octavio Microsoft Outlook Contacts 9 9th Dec 2008 10:44 PM
create a new distribution list using existing list =?Utf-8?B?R29yZG9uIE1jRG91Z2FsbA==?= Microsoft Outlook Contacts 1 21st May 2006 01:19 AM
how create new distribution list from names in existing list =?Utf-8?B?Y29udHJvbCBvZiBwb3NpdGlvbiB3aGVuIG11bHRp Microsoft Outlook Discussion 1 28th Sep 2005 10:31 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:40 PM.