Setting display name for a distribution list in Outlook

User avatar
ErikJan
BronzeLounger
Posts: 1258
Joined: 03 Feb 2010, 19:59
Location: Terneuzen, the Netherlands

Setting display name for a distribution list in Outlook

Post by ErikJan »

Manipulating Outlook distribution lists via VBA. All works fine.

One small question... I see in the Outlook address book that a DL has a "Name" and a "Display name". At this moment in time, they are the same. It would be great if the "Name" would stay the same but if I could change the "Display Name". I can't do that manually and quite frankly, I don't know if I could do that through code... My idea is to add a date to the display name. That way, if I update my DL, it will overwrite the old one (as the "Name" field is the same), but still the user sees when the DL was created....

So... my DL is named "myDL" and each new one therefore overwrites the old one. The display name would however be something like "myDL 2011.12.31"...

Here's parts of how I'm doing things now...

Creating a DL

Code: Select all

    Set olDL = olApp.CreateItem(7)    'olDistributionListItem
    olDL.DLName = DLName
    ' Create dummy mail
    Set olMail = olApp.CreateItem(0)    'olMailItem
Then add recipients to the MailItem:

Code: Select all

 Set olRec = olMail.Recipients.Add(RecipName)
Then add the recipients to the DL and save it:

Code: Select all

    olDL.AddMembers olMail.Recipients
    olDL.Save
Does anyone know? Maybe something like olDL.DLDisplayName???

User avatar
HansV
Administrator
Posts: 78609
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Setting display name for a distribution list in Outlook

Post by HansV »

That doesn't seem to be possible. The only relevant properties of a DistListItem object are DLName and Subject, but changing one of these sets the other to the same value.
(There is also a property TaskSubject. This can be set separately, but as the name indicates, it is only used when the DL is marked as a task)
Best wishes,
Hans

User avatar
ErikJan
BronzeLounger
Posts: 1258
Joined: 03 Feb 2010, 19:59
Location: Terneuzen, the Netherlands

Re: Setting display name for a distribution list in Outlook

Post by ErikJan »

Thanks Hans... I couldn't find it either. Strange that MS included the "Display Name" as header but don't do anything with it... Maybe I'm not surprised :-) but I thought I'd try