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

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

How do I check for an outlook folder and create it if it does not exist?

Hello, I would like to write a VB Script to be able to check for a folder in Outlook, Under the users mailbox, (Pelletier, John - Mailbox) and if it does not exist, create it.
0
JohnPell
Asked:
JohnPell
  • 4
  • 3
1 Solution
 
RobSampsonCommented:
There's a few examples here, although I don't use Outlook, but outlookcode.com is a great place to look for such a thing:
http://www.outlookcode.com/threads.aspx?forumid=5&messageid=7923
http://www.outlookcode.com/d/code/quarexe.htm

Regards,

Rob.
0
 
JohnPellAuthor Commented:
Thanks for the response, however these examples are in VBA and don't really cover what I need.
0
 
RobSampsonCommented:
What language do you need it in, and what are the exact steps you need to cover?

Rob.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
JohnPellAuthor Commented:
VB Script, found something from "The Scripting Guy" and wrote the below, which works.

Const olFolderInbox = 6

    Set objOutlook = CreateObject("Outlook.Application")
    Set objNamespace = objOutlook.GetNamespace("MAPI")
    Set objFolder = objNamespace.GetDefaultFolder(olFolderInbox)

    strFolderName = objFolder.Parent
    Set objMailbox = objNamespace.Folders(strFolderName)
    On Error Resume Next 'Mailbox already exists
    Set objNewFolder = objMailbox.Folders.Add("ImportToCall")
0
 
RobSampsonCommented:
Great, well done.

VBA can be quite easily converted to VBScript, usually just by taking out any type declarations, such as changing:
Dim strFolderName As String
to:
Dim strFolderName

The rest is fairly similar.

Anyway, nice solution....I would suggest posting a request in the Community Support zone to have this question either deleted, or PAQ'ed accepting your own answer.

Regards,

Rob.
0
 
JohnPellAuthor Commented:
I really appreciate your taking the time to answer!
0
 
RobSampsonCommented:
No worries.  Thanks JohnPell.

Rob.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

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