Outlook 10 Interop Issues

G

Guest

When trying to call this class to create an item in a public folder, I get
the following error:

Server execution failed

at VRInterop.Appointment.FindPublicFolder(String folderName) at
VRInterop.Appointment..ctor(String publicFolder, String subject, String body)
at VR.Confirm.ibtConfirm_Click(Object sender, ImageClickEventArgs e) in
c:\inetpub\wwwroot\vr\confirm.aspx.cs:line 162

VRInterop


The application calling this class is an ASP.Net app in C#. The server is
2000 Server and it has Office XP installed. There is a public folder
residing in Exchange 2000 and windows authentication is being used across the
board.

Any assistance is greatly appreciated.


public class Appointment
{
private Ol.MAPIFolder TaskFolder;
private Ol.Items tasks;
private string m_subject;
private string m_body;


public Appointment(string publicFolder, string subject, string body)
{
// Get a reference to the folder
TaskFolder = this.FindPublicFolder(publicFolder);
//Get a collection of the tasks
tasks = this.GetTasks();
//Set the subject and body
m_subject = subject;
m_body = body;
//Create the Appointment
this.Create();
}

private Ol.Items GetTasks()
{
/* GetTasks()
* This function returns a collection of task
* items from the specified folder object */
//Get the collection of items in the folder's default type
Ol.Items result = TaskFolder.Items;
return result;
}

public void Create()
{
/*The logic to creating the appointment(task) is simply
grabbing
* a reference to the collection of tasks within the folder and adding
* a new item, setting its properties and saving it. */

//Adding a task requires a cast. I honestly don't know why,
//but I got this from MSDN sample code.
Ol.TaskItem ti = (Ol.TaskItem)tasks.Add("IPM.Task");
ti.Subject = m_subject;
ti.Body = m_body;
ti.Save();
}

public Ol.MAPIFolder FindPublicFolder(string folderName)
{
/* FindPublicFolder()
* This function takes a string representing a folder
* and returns that object */

//Open the Outlook application
Ol._Application olApp = new Ol.ApplicationClass();
//Get a MAPI folder reference
Ol._NameSpace olNS = olApp.GetNamespace("MAPI");
//Iterate through folder hierarchy
//Get Upper Level folder set
Ol._Folders oFolders;
oFolders = olNS.Folders;
//Get the Public folder collection
Ol.MAPIFolder oPublicFolder = oFolders.Item("Public Folders");
oFolders = oPublicFolder.Folders;
//Get the All Public folders collection
Ol.MAPIFolder oAllPFolder = oFolders.Item("All Public Folders");
oFolders = oAllPFolder.Folders;
//Get the folder you're looking for
Ol.MAPIFolder oMyFolder = oFolders.Item(folderName);
return oMyFolder;
}

public override string ToString()
{
// Overridden from System.Object to produce something
// intelligent for the developer to see when needed.
string result = "Appointment Class\n";
result += "Current Folder: " + this.TaskFolder.Name.ToString() + "\n";
Ol.Items items = this.GetTasks();
result += "Item Count: " + items.Count.ToString();
return result;
}

}

Ryan Brady
(e-mail address removed)
 

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

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top