[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 490
  • Last Modified:

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
0
Bertling
Asked:
Bertling
  • 5
  • 3
  • 2
2 Solutions
 
Chris BottomleyCommented:
Sounds like:

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

Chris
0
 
Chris BottomleyCommented:
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
 
BertlingAuthor Commented:
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
Chris BottomleyCommented:
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
 
Chris BottomleyCommented:
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
 
Chris BottomleyCommented:
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
 
BertlingAuthor Commented:
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
 
Bill PrewCommented:
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
 
BertlingAuthor Commented:
thanks for your help guys it works a treat!
0
 
Bill PrewCommented:
Welcome, Chris is good.

~bp
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

  • 5
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now