Solved

VBScript: include sub distribution lists into one main list (to avoid size limitation).

Posted on 2011-02-25
4
395 Views
Last Modified: 2012-05-11
Hello,

I've a question related to this one.
The mentionned post was related to the size limitation of distribution list in Outlook 2007 SP1 and below.

The solution proposed (and accepted) was to created sub distribution lists with limited size and include them in a "main" list.
Unfortunately nor the proposed script neither several tested variants work (running Outlook 2003).
The result is always the same: the sub-lists are well created, but the main list remains empty.

Has anyone already tried to implement this solution? How?

Many thanks in advance for your help,
OssAdmin.
0
Comment
Question by:ossAdmin
  • 3
4 Comments
 
LVL 59

Expert Comment

by:Chris Bottomley
ID: 34978524
Whilst I cannot be sure of the issue with Patricks code, I had something similar in outlook which I have converted to VBS and tested in Outlook XP ... it appears ok.

I include some test lines to populate an array with data instead of line statements but as long as you pass bigdl an array with all the names and a string constant to be the DL name then it should work.

Note as presented it deletes any pre-existing DL of the same name.

Chris
For intLooper = 1 To 355
        ReDim Preserve arrAddresses(intLooper)
        arrAddresses(intLooper) = "TestAddress" & intLooper & "@domain.com"
    Next
    Set myDL = BigDL("TestDL", arrAddresses)

Function BigDL(strDLName, arrNames)
    set olkapp = createobject("outlook.application")
    killItem olkapp.Session.GetDefaultFolder(10), strDLName
    Set BigDL = olkapp.CreateItem(7)
    BigDL.DLName = strDLName
    For intBlock = 1 To UBound(arrNames) \ 100
        killItem olkApp.Session.GetDefaultFolder(10), strDLName & "_" & intBlock
        Set DL = olkApp.CreateItem(7)
        DL.DLName = strDLName & "_" & intBlock
        Set mai = olkApp.CreateItem(0)
        For intItem = 1 To 100
            If UBound(arrNames) < ((intBlock * 100) + intItem) Then Exit For
            With mai.Recipients
                .Add arrNames((intBlock * 100) + intItem)
            End With
        Next
        mai.Recipients.ResolveAll
        DL.AddMembers mai.Recipients
        DL.Save
        Set mai = olkApp.CreateItem(0)
        mai.recipients.add strDLName & "_" & intBlock
        mai.recipients.resolveall
        BigDL.AddMembers mai.recipients
    Next
    BigDL.Save
    mai.delete
    Set DL = Nothing
    Set mai = Nothing
    olkapp.quit

End Function

Sub killItem(fldr, strName)
    For itm = fldr.items.count To 1 Step -1
        With fldr.items(itm)
            If .Class = 69 Then
                If LCase(.DLName) = LCase(strName) Then .Delete
            End If
        End With
    Next
End Sub

Open in new window

0
 
LVL 59

Expert Comment

by:Chris Bottomley
ID: 34978559
Hmmm

I thought i'd check Patricks code as well ... and it works on the same XP machine so whilst you ought to try 'my' code it may be that it is no better.  It is slightly different in implementation so maybe ... maybe!

Chris
0
 

Author Comment

by:ossAdmin
ID: 34978715
Thanks Chris!
I'll test your proposal ASAP.

It's indeed too bad that the Patrick's script works for both of you but fails on all PCs on which I've tested it :-( ...

I'll keep you informed.
0
 
LVL 59

Accepted Solution

by:
Chris Bottomley earned 500 total points
ID: 34980285
It looks as though I used an old version when I converted it ... I found the one I supplied has a bug and another variant that retains the first block, (the supplied one misses some of the data) - I did sanity check it but failed to recognise the abscence of the first 100 datums.

I have not been able to test the below as VBS but the reqork required is fairly trivial so I believe this one will work correctly ... whether or not it displays the  primary DL correctly is of course another matter!

Chris
For intLooper = 1 To 355
    ReDim Preserve arrAddresses(intLooper)
    arrAddresses(intLooper) = "TestAddress" & intLooper & "@domain.com"
Next
Set myDL = BigDL("TestDL", arrAddresses)

Function BigDL(strDLName, arrNames)
    set olkapp = createobject("outlook.application")
    killItem olkapp.Session.GetDefaultFolder(10), strDLName
    Set BigDL = olkapp.CreateItem(7)
    BigDL.DLName = strDLName
    For intBlock = 0 To UBound(arrNames) \ 100
        killItem olkApp.Session.GetDefaultFolder(10), strDLName & "_" & intBlock
        Set DL = olkApp.CreateItem(7)
        DL.DLName = strDLName & "_" & intBlock
        Set mai = olkApp.CreateItem(0)
        For intItem = 1 To 100
            If UBound(arrNames) >= ((intBlock * 100) + intItem) Then
                With mai.Recipients
                    .Add arrNames((intBlock * 100) + intItem)
                End With
            end if
        Next
        mai.Recipients.ResolveAll
        DL.AddMembers mai.Recipients
        DL.Save
        Set mai = olkApp.CreateItem(0)
        mai.recipients.add strDLName & "_" & intBlock
        mai.recipients.resolveall
        BigDL.AddMembers mai.recipients
    Next
    BigDL.Save
    mai.delete
    Set DL = Nothing
    Set mai = Nothing
    olkapp.quit

End Function

Sub killItem(fldr, strName)
    For itm = fldr.items.count To 1 Step -1
        With fldr.items(itm)
            If .Class = 69 Then
                If LCase(.DLName) = LCase(strName) Then .Delete
            End If
        End With
    Next
End Sub

Open in new window

0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Learn more about how the humble email signature can be used as more than just an electronic business card. When used correctly, a signature can easily be tailored for different purposes by different departments within an organization.
Granting full access permission allows users to access mailboxes present in their database. By giving full access permission one can open and read the content of any mailbox but cannot send emails from that mailbox.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now