Solved

Script to delete outlook contacts container

Posted on 2011-09-08
10
486 Views
Last Modified: 2012-05-12
Hi there,

probably a easy one but can anyone advise a script that would delete a sub-contacts container in the outlooks default "Contacts" container called "BB Contacts".

FYI It is outlook 2010 which we use.

thanks,

mike
0
Comment
Question by:Bertling
[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
  • 5
  • 3
  • 2
10 Comments
 
LVL 59

Expert Comment

by:Chris Bottomley
ID: 36506242
Sounds like:

application.Session.GetDefaultFolder(10).Folders("bb contacts").delete

Chris
0
 
LVL 59

Expert Comment

by:Chris Bottomley
ID: 36506253
Note in the VBS context then application is replaced by a declaration to outlook for example:

set olkAPp = createobject("outlook.application")
olkapp.Session.GetDefaultFolder(10).Folders("bb contacts").delete

Chris
0
 
LVL 11

Author Comment

by:Bertling
ID: 36506337
hi thanks for this.

i created a VBS with the following code:

set olkAPp = createobject("outlook.application")
olkapp.Session.GetDefaultFolder(10).Folders("bb contacts").delete

and it errors "The attempt operation failed. and object could not be...."

if you could kindly advise what i need to paste int othe vbs that would be great.

thanks again,

mike
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 59

Accepted Solution

by:
Chris Bottomley earned 250 total points
ID: 36506389
Set olkapp = CreateObject("outlook.application")
olkapp.Session.GetDefaultFolder(10).Folders("bb contacts").Delete

Does it ... unless the folder isn't where I understand it to be ... i.e. as a sub folder of contacts.  Can you confirm where it is?

Chris
0
 
LVL 59

Expert Comment

by:Chris Bottomley
ID: 36506407
For eample in outlook itself set the cursor onto the folder then in the VBE type:


msgbox application.ActiveExplorer.CurrentFolder.FolderPath

What does it show?
0
 
LVL 59

Expert Comment

by:Chris Bottomley
ID: 36506446
Got to go but if it's at the same level then try:


Set olkapp = CreateObject("outlook.application")
olkapp.Session.GetDefaultFolder(10).parent.Folders("bb contacts").Delete
0
 
LVL 11

Author Comment

by:Bertling
ID: 36506457
Hi Chris,

that is great you were right sorry for my mistake in missing the s off the end of the sub container.

the next thing i have noticed is that it will put it into the deleted items. is it possible to permanently delete it? it may need to be deleted in the same way but then instead under the "Deleted Items" container...
thanks,

mike
0
 
LVL 55

Assisted Solution

by:Bill Prew
Bill Prew earned 250 total points
ID: 36506472
Sounded like Chris may have had to leave, so let me see if I can help.  Try this, it should remove it from the deleted items folder as well.

Set olkapp = CreateObject("outlook.application")
olkapp.Session.GetDefaultFolder(10).Folders("bb contacts").Delete
olkapp.Session.GetDefaultFolder(3).Folders("bb contacts").Delete

~bp
0
 
LVL 11

Author Comment

by:Bertling
ID: 36506826
thanks for your help guys it works a treat!
0
 
LVL 55

Expert Comment

by:Bill Prew
ID: 36506957
Welcome, Chris is good.

~bp
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Utilizing an array to gracefully append to a list of EmailAddresses
Find out what Office 365 Transport Rules are, how they work and their limitations managing Office 365 signatures.
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Many of my clients call in with monstrous Gmail overloading issues with Outlook. A quick tip is to turn off the All Mail and Important folders from synching. Here is a quick video I made to show you how to turn off these and other folders in Gmail s…

729 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