Adding a distribution list to my own contacts folder.

N

neilsg2001

Hi,

I have successfully managed to create contacts and put them in into a
distribution list. I have modified this to create the contacts in my
own contacts, (not the root default contacts folder). How do I know
create a distribution list in the new contacts folder?

The current code creates the dist list in the root contact folder and a
move is attempted. This just leaves me with two dist lists which are
both empty.

Thanks in advance.

Neil

**START CODE**
var objOutlook = new ActiveXObject("Outlook.Application")
var objOutlookMsg =
objOutlook.CreateItemFromTemplate(this.templatePath);
var objTempItem = objOutlook.CreateItem(olMailItem);
var objContact
var objRecipients = objTempItem.Recipients;
var objDistList = objOutlook.CreateItem(olDistributionListItem);
objDistList.DLName = GROUPNAME;

var objNamespace = objOutlook.GetNamespace('MAPI');
var objFolder = objNamespace.GetDefaultFolder(olFolderContacts);
var objNewFolder = objFolder.Folders.Add(GROUPNAME);
var objContact = objNewFolder.items.add();
//objDistList.parent = objNewFolder;
//var objDistList = objNewFolder.Folders.add('test',
olDistributionListItem);

var record;
var email;
var objContact;
for (var i=0;i<nodeList.length;i++)
{
record = nodeList;
email = record.getAttribute('emailaddress');

//objContact = objOutlook.CreateItem(olContactItem);
//objContact = objNewFolder.items.add();
objContact.email1address = email;
objContact.FileAs = objContact.email1address;
objContact.Save();

objRecipients.add(objContact.email1address);
}

objRecipients.ResolveAll();
objDistList.AddMembers(objRecipients);

objDistList.Save();

objOutlookMsg.Subject = this.subject;
//objOutlookMsg.Body =
objOutlookMsg.Importance = olImportanceNormal;

var objRecipient = objOutlookMsg.Recipients.Add(objDistList.DLName);
objRecipient.Type = olBCC;
objRecipient.Resolve();

objOutlookMsg.Save(); //Save mail to draft folder. You can call
save method to send the email
**END CODE**
 
N

Neil

Thanks Sue,

Now i have my contacts in a dist list in the sub contacts folder where
I want them.

When i try to use the dist list for the to or bcc field of an email,
neither the contact folder or distlist is available or valid??!!


Neil
 
S

Sue Mosher [MVP-Outlook]

Did you check the box on the Properties dialog of the folder that exposes
that folder through the Outlook Address Book?
 
N

Neil

Thanks.

myMapiFolder.ShowAsOutlookAB = true

outlook 2002 onwards only - damn

:(

Maybe i'll just put the email addresses in a distribution list in the
root contacts folder and then delete any contacts required to do this
afterwards.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top