|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
using Outlook = Microsoft.Office.Interop.Outlook;
using Office = Microsoft.Office.Core;
namespace CustomAddressDialog
{
/// <summary>
/// Class with helpermethods for Outlookspecific functionality
/// </summary>
internal class OutlookUtility
{
/// <summary>
/// Returns the Table Object for the given default folder.
/// </summary>
/// <param name="defaultFolder">The Default</param>
/// <param name="filter">A filter that could be passed to filter items.</param>
/// <returns>Returns the folder Table object.</returns>
public static Outlook.Table GetFolderTable(Outlook.OlDefaultFolders defaultFolder, string filter)
{
Outlook.MAPIFolder folder = Globals.ThisAddIn.Application.Session.GetDefaultFolder(defaultFolder);
return GetFolderTable(ref folder, filter);
}
/// <summary>
/// Returns the Table Object for the passed folder.
/// </summary>
/// <param name="defaultFolder">The Default</param>
/// <param name="filter">A filter that could be passed to filter items.</param>
/// <returns>Returns the folder Table object.</returns>
public static Outlook.Table GetFolderTable(ref Outlook.MAPIFolder folder, string filter)
{
return folder.GetTable(filter, Missing.Value);
}
/// <summary>
/// Prepares the Tableobject on what data to retrieve.
/// </summary>
/// <param name="table">The Table object</param>
/// <param name="columnNames">An arry of columnnames</param>
public static void SetTableColumns(ref Outlook.Table table, string[] columnNames)
{
table.Columns.RemoveAll();
foreach (string columnName in columnNames)
{
table.Columns.Add(columnName);
}
}
/// <summary>
/// Returns the value of an COM Object property using latebinding.
/// </summary>
/// <param name="item">The COM Object passed as reference.</param>
/// <param name="propertyName">The name of the property to retrieve.</param>
/// <returns>The property value as Object.</returns>
public static object PropertyGet(ref object item, string propertyName)
{
return item.GetType().InvokeMember(propertyName, System.Reflection.BindingFlags.GetProperty, null, item, null);
}
/// <summary>
/// Returns the value of an COM Object property using latebinding.
/// </summary>
/// <param name="item">The COM object passed by reference.</param>
/// <param name="propertyName">The name of the property to set.</param>
/// <param name="value">The property value as object.</param>
public static void PropertySet(ref object item, string propertyName, object value)
{
item.GetType().InvokeMember(propertyName, System.Reflection.BindingFlags.SetProperty, null, item, new object[] { value });
}
/// <summary>
/// Returns the Path to MyDocuments
/// </summary>
public static string GetMyDocumentsFolder()
{
return Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
}
/// <summary>
/// Returns the Path to Local Application Data folder
/// </summary>
public static string GetLocalAppDataFolder()
{
return Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
I'm a 1968 model, made in Germany.
After School transformed into an electronic engineer and started repairing computers in 1986. From PET till now In the IT-world. Currently employed as softwaredeveloper in a company creating solutions for pharmacies.
MCSE2000, MCSD, MCTS - Team Foundation Server, MCTS - Visual Studio Tools for Office.
Specialized in Outlook/Exchange custom development. Languages: german, english, C#, C++, VB.Net, VB6, SQL.
In 2006 received an award as MVP - Visual Developer VSTO by Microsoft.
Homepage: [http://www.x4u.de]