Link to home
Create AccountLog in
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
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

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

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
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
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
Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
thanks for your help guys it works a treat!
Avatar of Bill Prew
Bill Prew

Welcome, Chris is good.

~bp