Solved

Script to delete outlook contacts container

Posted on 2011-09-08
10
485 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
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!

 
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 54

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 54

Expert Comment

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

~bp
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

This story has been written with permission from the scammed victim, a valued client of mine – identity protected by request.
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
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: …
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

749 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