How Open Existing Calendar C#

S

Steve B.

Now that I found the Outlook public folder containing an existing
calendar, how do I open it ?

And , what if the XP network user has Outlook closed or minimized in the
background how should I address Logon() or do I need to address it.

************************
openOutlookFolder(string publicFolderLevel1, ..2, ..3)
{

Application olApp = new ApplicationClass();
NameSpace olNS = olApp.GetNamespace("MAPI");

MAPIFolder objFolder
= olNS.GetDefaultFolder(.OlDefaultFolders.olPublicFoldersAllPublicFolders);

//nested foreach & if at third level
foreach (objfolder3 in objfolder2.Folders)
{
if (objfolder3.Name == publicFolderLevel3)
{
//I found folder containing the existing "confRoomCalendar"
//How do I open it in Outlook?
}
}

}
 
S

Sue Mosher [MVP-Outlook]

You can either set ActiveExplorer.CurrentFolder to that calendar or, to show
it in
another window, use the MAPIFolder.Display method.
 
H

Helmut Obertanner

Hi Steve, hi Sue

here is a nice trick.
Use the embedded "Goto... Folder" Control.

Just put in the FolderPath / Name, and Outlook changes to your Folder.

Greets, Helmut Obertanner
/// <summary>

/// Change the Explorer to another Folder

/// </summary>

/// <param name="FolderPath"></param>

private void GotoFolder(string FolderPath)

{

try

{

Office.CommandBarComboBox myCombo = (Office.CommandBarComboBox)
myOutlookExplorer.CommandBars.FindControl(26, 1740,myMissing,myMissing);

if (myCombo != null)

{

myCombo.Text = FolderPath;

Marshal.ReleaseComObject (myCombo);

}

}

catch (System.Exception ex)

{

// TODO: Log Error

}

}
 
S

Steve B.

Sorry Sue - I guess I don't understand

The method below selects the proper folder, but the folder, containing the
calendars, is closed (plus sign). If you open the folder the calendars
show. In addition, the folder pane in Outlook does not move to show the
selected highlighted folder to the user (you have to scroll down to the
folder and then open it up)

How can I move the user Outlook folder pane so the folder selected is shown
in the pane and open the folder so they see the calendars.

if (objfolder3.Name == publicFolderLevel3)
{
//objfolder3.Display(); // highlights proper folder

.....Outlook.Explorer explorers = objfolder3.GetExplorer(...Normal);
//now what do I do?
explorers.Activate(); // highlights proper folder
}
 
S

Sue Mosher [MVP-Outlook]

Outlook version? Did you try setting ActiveExplorer.CurrentFolder?
--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
S

Steve B.

Sue,

Outlook verision 2003, SP1

I understand why the code below runs right by the calendar I want, my
problem is how to stop it and open it up properly. Comments? Seems to
debug O'k.

Steve

if (objfolder3.Name == publicFolderLevel3)
{
....Interop.Outlook.Explorer olExplorer = olApp.ActiveExplorer();

IEnumerator EmpEnumerator = objfolder3.Folders.GetEnumerator();
EmpEnumerator.Reset();

// 6 = objfolder3.Folders.Count;

while(EmpEnumerator.MoveNext())
{
olExplorer.CurrentFolder = (....MAPIFolder)EmpEnumerator.Current;

if(olExplorer.Caption.ToString() == confRmName)
{
olExplorer.Activate();
//olExplorer.CurrentFolder = null;
//EmpEnumerator= null;
//break;
}
}
 
S

Sue Mosher [MVP-Outlook]

I still don't understand what you mean by "properly," but if you want to
show an additional folder in the Calendar pane, you set
ActiveExplorer.IsFolderSelected.

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
H

Helmut Obertanner

Hello Sue, hello Steve,

i have a function here, don't know if it helps.
It uses the Built in Outlook function from CommandBar "GoToFolder":

myOutlookExplorer is the ActiveExplorer.

The FolderPath is something like:

"PublicCalendar"

or

"res://C:\CRM\webresource.dll/index.htm"

for an FolderHomepage from a dll.


/// <summary>

/// Change the Explorer to another Folder

/// </summary>

/// <param name="FolderPath"></param>

private void GotoFolder(string FolderPath)

{

try

{

Office.CommandBarComboBox myCombo = (Office.CommandBarComboBox)
myOutlookExplorer.CommandBars.FindControl(26, 1740,myMissing,myMissing);

if (myCombo != null)

{

myCombo.Text = FolderPath;

Marshal.ReleaseComObject (myCombo);

}

}

catch (System.Exception ex)

{

Logger.LogError (CLASS_NAME , "GotoFolder",ex,FolderPath);

}

}

Hope that Helps,

Greets, Helmut Obertanner.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top