Avatar of Bertling
BertlingFlag for United Kingdom of Great Britain and Northern Ireland

asked on 

Script to delete outlook contacts container

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
VB ScriptShell ScriptingEmail Clients

Avatar of undefined
Last Comment
Bill Prew
Avatar of Chris Bottomley
Chris Bottomley
Flag of United Kingdom of Great Britain and Northern Ireland image

Sounds like:

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

Chris
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
Avatar of Bertling
Bertling
Flag of United Kingdom of Great Britain and Northern Ireland image

ASKER

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
ASKER CERTIFIED SOLUTION
Avatar of Chris Bottomley
Chris Bottomley
Flag of United Kingdom of Great Britain and Northern Ireland image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
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?
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
Avatar of Bertling
Bertling
Flag of United Kingdom of Great Britain and Northern Ireland image

ASKER

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
SOLUTION
Avatar of Bill Prew
Bill Prew

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
Avatar of Bertling
Bertling
Flag of United Kingdom of Great Britain and Northern Ireland image

ASKER

thanks for your help guys it works a treat!
Avatar of Bill Prew
Bill Prew

Welcome, Chris is good.

~bp
VB Script
VB Script

VBScript (Visual Basic Scripting Edition) is an interpreted scripting language developed by Microsoft that is modeled on Visual Basic, but with some important differences. VBScript is commonly used for automating administrative and other tasks in Windows operating systems (by means of the Windows Script Host) and for server-side scripting in ASP web applications. It is also used for client-side scripting in Internet Explorer, specifically in intranet web applications.

39K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo