I am attempting to automate the creation of an Outlook Task using JavaScript in a local IE-only environment (using Outlook 2007/2010). I have been able to do so using an Outlook ActiveX object, with one minor catch, my method creates the task in the user’s default mailbox. (The 9 in the code below is the enumerated constant for the task folder)
What I need to do is create the task in a separate shared mailbox. I am looking for a way to set the task to the specific shared mailbox (that the user has access to) by name rather than the user’s personal (default) folder. What I have so far is below.
function createTask() {
//create Outlook object and map to the task folder
var outlookApp = new ActiveXObject("Outlook.Application");
var nameSpace = outlookApp.getNameSpace("MAPI");
var mailFolder = nameSpace.getDefaultFolder(9); //olFolderTask
//create the task
var task = mailFolder.Items.add('IPM.Task');
//set task properties
task.Subject = 'Subject';
task.Body = "Body of Task";
task.StartDate = "01/01/2012";
task.DueDate = "06/01/2012";
task.ReminderSet = true;
task.Save();
}
I have found some potentially useful information here, with an alternate to the getDefaultFolder function in GetFolderFromID, but I have not been able to find a way using JavaScript/ActiveX to get the needed EntryID just from the Shared Mailbox’s name.
I am new to working with Outlook, any suggestions or guidance would be appreciated. Thanks!
Try using the
Session.Storesas discussed in this SO post. It contains all the available mailbox stores (Store) a user has in their profile.Once you’ve identified the
Storeyou’re after, you can useStore.GetDefaultFolderto retrieve the shared mailbox taskFolderyou are interested in.