Pregunta

Currently I am aimed to create Outlook Add-in, which would create specific archive folder. The difference from the regular one is that mine should provide me full control over item's content during its move-in or move-out.

Shortly speaking, I should be able to scan items's binary content before its really moved into my folder or deleted from my folder. Im going to copy some of that items to network place.

Please advice my right documentation or samples for my situation

¿Fue útil?

Solución

Assuming that you're using Visual Studio 2010, you'll most likely start by creating a Visual Studio Tools for Office (VSTO) project to create your add-in. Look here for details on VSTO and Visual Studio.

Once you have that up and running, you will have a source file called ThisAddIn.cs that contains the "main entry point" into your add-in. From there, you can hook into events that Outlook will raise when certain events take place. You will most likely be interested in the following events:

  • BeforeFolderSwitch
  • FolderSwitch

Your code will look something like this:

private void ThisAddIn_Startup(object sender, EventArgs e)
{
    var explorer = this.Application.ActiveExplorer();
    explorer.BeforeFolderSwitch += new ExplorerEvents_10_BeforeFolderSwitchEventHandler(explorer_BeforeFolderSwitch);
    explorer.FolderSwitch += new ExplorerEvents_10_FolderSwitchEventHandler(explorer_FolderSwitch);
}

/// <summary>
/// Handler for Outlook's "BeforeFolderSwitch" event. This event fires before the explorer goes to
/// a new folder, either as a result of user action or through program code.
/// </summary>
/// <param name="NewlySelectedFolderAsObject">
/// The new folder to which navigation is taking place. If, for example, the user moves from "Inbox"
/// to "MyMailFolder", the new current folder is a reference to the "MyMailFolder" folder.
/// </param>
/// <param name="Cancel">
/// A Boolean describing whether or not the operation should be canceled.
/// </param>
void explorer_BeforeFolderSwitch(object NewlySelectedFolderAsObject, ref bool Cancel)
{
    if (NewlySelectedFolderAsObject == null)
        return;
    var newlySelectedFolderAsMapiFolder = NewlySelectedFolderAsObject as MAPIFolder; 
}

void explorer_FolderSwitch()
{
}

Your code should be placed in those event handlers to perform your work.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top