Solved

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

Posted on 2011-02-25
4
405 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Outlook 2016 search not function 4 49
Remove Exif Orientation before adding image to db 9 42
Exchange 2007 6 23
Powershell PGP and SFTP 1 18
This process describes the steps required to Import and Export data from and to .pst files using Exchange 2010. We can use these steps to export data from a user to a .pst file, import data back to the same or a different user, or even import data t…
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …
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: …

733 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