Create new item in public folder using VBscript

Not open for further replies.


New Member
Outlook version
Outlook 2013 64 bit
Email Account
Exchange Server 2013
Hi everyone. I'm trying to create a new task item based on a custom form, which will be executed by a button in that form. The custom form folder is in a public folder.

For now I have the following code in my custom form:
Sub cmdKorrFart_Click()
    Dim myFolder, myTask
    Set myFolder = Application.ActiveExplorer.CurrentFolder
    Set myTask = myFolder.Items.Add
End Sub
That works as long as I'm in that public folder. But if I go into the inbox to - for example - copy something from a mail into the form, then the inbox suddenly becomes the current folder, so then the code creates a mail item instead of a task item based on the form, unless I actively go back into the public folder by selecting it.

So my question is: How can I make Outlook create a new task item without using the CurrentFolder method? The public folder is in this location: All Public Folders\Sites\Romeo\Production\BIS\Booking\BookingForm.

I'm guessing it involves using GetDefaultFolder, but I'm not sure how to put it all together.


Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
You need to reference the folder path and walk down. It's not recommended to use too many dots in the path, so you'll need to work your way down if its nested
Set myPF = Session.GetDefaultFolder(olPublicFoldersAllPublicFolders).Folders("sites")
set myPFtree = mypf.folders("romeo").folders("production")
set mytaskfolder = myPFtree("bis").folders("booking").folders("bookingform")
Not open for further replies.