Solved

Script to delete outlook contacts container

Posted on 2011-09-08
10
480 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
  • 5
  • 3
  • 2
10 Comments
 
LVL 59

Expert Comment

by:Chris Bottomley
Comment Utility
Sounds like:

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

Chris
0
 
LVL 59

Expert Comment

by:Chris Bottomley
Comment Utility
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
Comment Utility
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
 
LVL 59

Accepted Solution

by:
Chris Bottomley earned 250 total points
Comment Utility
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
Comment Utility
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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 59

Expert Comment

by:Chris Bottomley
Comment Utility
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
Comment Utility
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 51

Assisted Solution

by:Bill Prew
Bill Prew earned 250 total points
Comment Utility
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
Comment Utility
thanks for your help guys it works a treat!
0
 
LVL 51

Expert Comment

by:Bill Prew
Comment Utility
Welcome, Chris is good.

~bp
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This article is essential to make secure Yahoo Mail connection without facing any issue. It is providing simple steps to configure your Yahoo Mailbox to Hard drive using Microsoft Outlook.
Check out this infographic on what you need to make a good email signature that will work perfectly for your organization.
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…
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: …

744 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now