Click here to Skip to main content
15,918,333 members
Home / Discussions / C#
   

C#

 
GeneralRe: which dll need to be imported to customize PrintPreviewDialog Pin
Heath Stewart13-May-04 2:30
protectorHeath Stewart13-May-04 2:30 
GeneralBeginInvoke Pin
Hugo Hallman9-May-04 12:50
Hugo Hallman9-May-04 12:50 
GeneralRe: BeginInvoke Pin
Heath Stewart10-May-04 3:57
protectorHeath Stewart10-May-04 3:57 
GeneralRe: BeginInvoke Pin
Hugo Hallman10-May-04 5:29
Hugo Hallman10-May-04 5:29 
GeneralRe: BeginInvoke Pin
Heath Stewart10-May-04 5:34
protectorHeath Stewart10-May-04 5:34 
GeneralEmail clients Pin
wfe9-May-04 12:13
wfe9-May-04 12:13 
GeneralRe: Email clients Pin
Dave Kreskowiak10-May-04 0:11
mveDave Kreskowiak10-May-04 0:11 
GeneralRe: Email clients Pin
wfe10-May-04 1:17
wfe10-May-04 1:17 
Thanks Dave,

Q1a: How do I search 'installed applications list' on a local PC from C#/.NET ?

Q1b: How do I search the registry ?

If I ask the user for what they use, I still have the problem of addressing the mailboxes locally on Outlook Express. Also, I would like to learn the Windows API and general environment by making the application 'fool proof'.

I don't know where the class came from - probably a former colleaque of mine.

I have enclosed the class below.

Thanks for your help


William

<br />
using System;<br />
using System.Data;<br />
using System.Diagnostics;<br />
using System.Windows.Forms;<br />
<br />
namespace test<br />
{<br />
	/// <summary><br />
	/// Delegate declaration for each time an item is processed from an Outlook folder.<br />
	/// </summary><br />
	public delegate void OutlookItemProcessed();<br />
<br />
	/// <summary><br />
	/// This disposable class acts a translator for information stored in the user's Outlook folders.<br />
	/// </summary><br />
	public class OutlookConnector : IDisposable<br />
	{<br />
		private Outlook.Application objOutlook = null;<br />
		private Outlook.NameSpace objNamespace = null;<br />
		private Outlook.MAPIFolder objFolder = null;<br />
		private Outlook.Items objItems = null;<br />
		public event OutlookItemProcessed ItemProcessed;<br />
<br />
		public OutlookConnector()<br />
		{<br />
			objOutlook = new Outlook.ApplicationClass();<br />
			objNamespace = objOutlook.GetNamespace("MAPI");<br />
		}<br />
<br />
		/// <summary><br />
		/// Close the Outlook application when this instance is disposed.<br />
		/// </summary><br />
		public void Dispose()<br />
		{<br />
			if (objOutlook != null) objOutlook.Quit();<br />
		}<br />
<br />
		/// <summary><br />
		/// Get the number of items within the specified default Outlook folder.<br />
		/// </summary><br />
		/// <param name="folder">outlook folder enumerated value</param><br />
		/// <returns>total number of items</returns><br />
		public int getFolderCount(Outlook.OlDefaultFolders folder)<br />
		{<br />
			objFolder = objNamespace.GetDefaultFolder(folder);<br />
			return objFolder.Items.Count;<br />
		}<br />
<br />
		/// <summary><br />
		/// Retrieve a list of all appointments listed in the Outlook calendar.<br />
		/// </summary><br />
		/// <returns>Calendar Items DataSet</returns><br />
		public DataSet getCalendarDataSet()<br />
		{<br />
			Outlook.AppointmentItem item;<br />
			DataSet rv = new DataSet();<br />
			rv.DataSetName = "Calendar";<br />
			rv.Tables.Add("Appointment");<br />
			rv.Tables[0].Columns.Add("Subject");<br />
			rv.Tables[0].Columns.Add("Location");<br />
			rv.Tables[0].Columns.Add("Start");<br />
			rv.Tables[0].Columns.Add("End");<br />
			rv.Tables[0].Columns.Add("AllDayEvent");<br />
			rv.Tables[0].Columns.Add("Duration");<br />
			rv.Tables[0].Columns.Add("Organizer");<br />
			rv.Tables[0].Columns.Add("Importance");<br />
			rv.Tables[0].Columns.Add("Sensitivity");<br />
			rv.Tables[0].Columns.Add("Body");<br />
<br />
			try<br />
			{<br />
				objFolder = objNamespace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar);<br />
				Debug.WriteLine(objFolder.Items.Count + " Appointments found.");<br />
				for (int i=0; i < objFolder.Items.Count; i++) <br />
				{<br />
					item = (Outlook.AppointmentItem)objFolder.Items.Item(i);<br />
					rv.Tables[0].Rows.Add(new object[] {<br />
						item.Subject,<br />
						item.Location,<br />
						item.Start,<br />
						item.End,<br />
						item.AllDayEvent,<br />
						item.Duration,<br />
						item.Organizer,<br />
						item.Importance,<br />
						item.Sensitivity,<br />
						item.Body<br />
					});<br />
					this.ItemProcessed();<br />
				}<br />
				Debug.WriteLine(rv.Tables[0].Rows.Count + " Appointments exported.");<br />
			}<br />
			catch (System.Exception e)<br />
			{<br />
				Console.WriteLine(e);<br />
			}<br />
			return rv;<br />
		}<br />
<br />
		/// <summary><br />
		/// Retrieves a list of all the Outlook Contacts.<br />
		/// </summary><br />
		/// <returns>Contact Items DataSet</returns><br />
		public DataSet getContactDataSet()<br />
		{<br />
			Outlook.ContactItem item;<br />
			DataSet rv = new DataSet();<br />
			rv.DataSetName = "Contacts";<br />
			rv.Tables.Add("Contact");<br />
			rv.Tables[0].Columns.Add("FirstName");<br />
			rv.Tables[0].Columns.Add("LastName");<br />
			rv.Tables[0].Columns.Add("CompanyName");<br />
			rv.Tables[0].Columns.Add("Email");<br />
			rv.Tables[0].Columns.Add("HomePhone");<br />
			rv.Tables[0].Columns.Add("WorkPhone");<br />
<br />
			try<br />
			{<br />
				objFolder = objNamespace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts);<br />
				Debug.WriteLine(objFolder.Items.Count + " Contacts found.");<br />
				for (int i=0; i < objFolder.Items.Count; i++) <br />
				{<br />
					item = (Outlook.ContactItem)objFolder.Items.Item(i);<br />
					rv.Tables[0].Rows.Add(new object[] {<br />
						item.FirstName,<br />
						item.LastName,<br />
						item.CompanyName,<br />
						item.Email1Address,<br />
						item.HomeTelephoneNumber,<br />
						item.BusinessTelephoneNumber<br />
					});<br />
					this.ItemProcessed();<br />
				}<br />
				Debug.WriteLine(rv.Tables[0].Rows.Count + " Contacts exported.");<br />
			}<br />
			catch (System.Exception e)<br />
			{<br />
				Console.WriteLine(e);<br />
			}<br />
			return rv;<br />
		}<br />
<br />
		/// <summary><br />
		/// Retrieves a list of all emails in the Outlook Inbox.<br />
		/// </summary><br />
		/// <returns>Inbox E-Mail Items DataSet</returns><br />
		public DataSet getInboxDataSet()<br />
		{<br />
			Outlook.MailItem item;<br />
			DataSet rv = new DataSet();<br />
			rv.DataSetName = "InboxEmails";<br />
			rv.Tables.Add("Email");<br />
			rv.Tables[0].Columns.Add("Name");<br />
			rv.Tables[0].Columns.Add("To");<br />
			rv.Tables[0].Columns.Add("Cc");<br />
			rv.Tables[0].Columns.Add("Subject");<br />
			rv.Tables[0].Columns.Add("Received");<br />
			rv.Tables[0].Columns.Add("Message");<br />
<br />
<br />
			try<br />
			{<br />
				objFolder = objNamespace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox);	<br />
				objItems = objFolder.Items.Restrict("[MessageClass]='IPM.Note'");<br />
<br />
				///strFind = "[Start] <= """ & FormatDateTime(currentDate,  vbShortDate)<br />
<br />
				Debug.WriteLine(objItems.Count + " E-Mails found.");<br />
				for (int i=1; i <= objItems.Count; i++) <br />
				{<br />
					item = (Outlook.MailItem)objItems.Item(i);				<br />
					{<br />
						rv.Tables[0].Rows.Add(new object[] {<br />
															   item.SenderName,<br />
															   item.To,<br />
															   item.CC,<br />
															   item.Subject,<br />
															   item.ReceivedTime,<br />
															   item.Body<br />
														   });<br />
	<br />
					}<br />
					this.ItemProcessed();<br />
				}<br />
				Debug.WriteLine(rv.Tables[0].Rows.Count + " E-Mails exported.");<br />
<br />
			}<br />
			catch (System.Exception e)<br />
			{<br />
				Console.WriteLine(e);<br />
			}<br />
			return rv;<br />
		}<br />
<br />
		/// <summary><br />
		/// Retrieves a list of all Outlook Notes.<br />
		/// </summary><br />
		/// <returns>Note Items DataSet</returns><br />
		public DataSet getNoteDataSet()<br />
		{<br />
			Outlook.NoteItem item;<br />
			DataSet rv = new DataSet();<br />
			rv.DataSetName = "Notes";<br />
			rv.Tables.Add("Note");<br />
			rv.Tables[0].Columns.Add("Subject");<br />
			rv.Tables[0].Columns.Add("Categories");<br />
			rv.Tables[0].Columns.Add("CreationTime");<br />
			rv.Tables[0].Columns.Add("LastModificationTime");<br />
			rv.Tables[0].Columns.Add("Contents");<br />
<br />
			try<br />
			{<br />
				objFolder = objNamespace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderNotes);<br />
				Debug.WriteLine(objFolder.Items.Count + " Notes found.");<br />
				for (int i=0; i < objFolder.Items.Count; i++) <br />
				{<br />
					item = (Outlook.NoteItem)objFolder.Items.Item(i);<br />
					rv.Tables[0].Rows.Add(new object[] {<br />
						item.Subject,<br />
						item.Categories,<br />
						item.CreationTime,<br />
						item.LastModificationTime,<br />
						item.Body<br />
					});<br />
					this.ItemProcessed();<br />
				}<br />
				Debug.WriteLine(rv.Tables[0].Rows.Count + " Notes exported.");<br />
			}<br />
			catch (System.Exception e)<br />
			{<br />
				Console.WriteLine(e);<br />
			}<br />
			return rv;<br />
		}<br />
<br />
		/// <summary><br />
		/// Retrieves a list of all Outlook Tasks.<br />
		/// </summary><br />
		/// <returns>Task Items DataSet</returns><br />
		public DataSet getTaskDataSet()<br />
		{<br />
			Outlook.TaskItem item;<br />
			DataSet rv = new DataSet();<br />
			rv.DataSetName = "Tasks";<br />
			rv.Tables.Add("Task");<br />
			rv.Tables[0].Columns.Add("Subject");<br />
			rv.Tables[0].Columns.Add("StartDate");<br />
			rv.Tables[0].Columns.Add("DueDate");<br />
			rv.Tables[0].Columns.Add("Status");<br />
			rv.Tables[0].Columns.Add("Contents");<br />
<br />
			try<br />
			{<br />
				objFolder = objNamespace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderTasks);<br />
				Debug.WriteLine(objFolder.Items.Count + " Tasks found.");<br />
				for (int i=0; i < objFolder.Items.Count; i++) <br />
				{<br />
					item = (Outlook.TaskItem)objFolder.Items.Item(i);<br />
					rv.Tables[0].Rows.Add(new object[] {<br />
						item.Subject,<br />
						item.StartDate,<br />
						item.DueDate,<br />
						item.Status,<br />
						item.Body<br />
					});<br />
					this.ItemProcessed();<br />
				}<br />
				Debug.WriteLine(rv.Tables[0].Rows.Count + " Tasks exported.");<br />
			}<br />
			catch (System.Exception e)<br />
			{<br />
				Console.WriteLine(e);<br />
			}<br />
			return rv;<br />
		}<br />
	}<br />
}<br />
<br />

GeneralRe: Email clients Pin
Heath Stewart10-May-04 3:49
protectorHeath Stewart10-May-04 3:49 
GeneralRe: Email clients Pin
wfe10-May-04 7:59
wfe10-May-04 7:59 
GeneralRe: Email clients Pin
Heath Stewart10-May-04 8:58
protectorHeath Stewart10-May-04 8:58 
GeneralRe: Email clients Pin
wfe10-May-04 9:23
wfe10-May-04 9:23 
GeneralRe: Email clients Pin
Heath Stewart10-May-04 9:43
protectorHeath Stewart10-May-04 9:43 
GeneralRe: Email clients Pin
wfe11-May-04 3:00
wfe11-May-04 3:00 
GeneralRe: Email clients Pin
Heath Stewart11-May-04 3:12
protectorHeath Stewart11-May-04 3:12 
GeneralMemory Usage of a console application Pin
eranas9-May-04 10:25
eranas9-May-04 10:25 
GeneralRe: Memory Usage of a console application Pin
Jeff Varszegi9-May-04 12:11
professionalJeff Varszegi9-May-04 12:11 
GeneralRe: Memory Usage of a console application Pin
Heath Stewart10-May-04 3:39
protectorHeath Stewart10-May-04 3:39 
GeneralMouse Drag Event Pin
Member 6910899-May-04 7:15
Member 6910899-May-04 7:15 
GeneralRe: Mouse Drag Event Pin
Mazdak9-May-04 7:52
Mazdak9-May-04 7:52 
GeneralFree disk space Pin
kratchkov9-May-04 5:15
kratchkov9-May-04 5:15 
GeneralRe: Free disk space Pin
Mazdak9-May-04 5:21
Mazdak9-May-04 5:21 
GeneralRe: Free disk space Pin
kratchkov9-May-04 5:30
kratchkov9-May-04 5:30 
GeneralRe: Free disk space Pin
Mike Dimmick9-May-04 7:12
Mike Dimmick9-May-04 7:12 
GeneralRe: Free disk space Pin
kratchkov9-May-04 7:36
kratchkov9-May-04 7:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.