Solved

Script to delete outlook contacts container

Posted on 2011-09-08
10
482 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
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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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 52

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 52

Expert Comment

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

~bp
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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
PHP contact form that lets the user to contact the company through email contact form. A button is fixed at the bottom of site, on clicking a new window will open where a user can send the email.
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: …

863 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

24 Experts available now in Live!

Get 1:1 Help Now