Skip to content

Instantly share code, notes, and snippets.

@NathanW2
Created August 31, 2010 06:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NathanW2/558661 to your computer and use it in GitHub Desktop.
Save NathanW2/558661 to your computer and use it in GitHub Desktop.
Comparing C# with and with the {. Using indention like Python. Just for fun
public class Outlook
{
private Application outlook;
private Outlook(Application outlookInstance)
{
this.outlook = outlookInstance;
this.DBYDEmailFolderName = "DBYD";
}
public static Outlook ConnectToOutlook()
{
try
{
Application instance = new ApplicationClass();
return new Outlook(instance);
}
catch (System.Exception)
{
throw new ApplicationException("Could not connect to outlook");
}
}
public string CurrentUser
{
get
{
return this.outlook.GetNamespace("MAPI").CurrentUser.Name;
}
}
public bool HasDBYDFolder
{
get
{
return (this.DBYDFolder != null);
}
}
public int CountOfUnreadItems
{
get
{
var itemlist = this.DBYDFolder.Items.Restrict("[Unread] = true");
return itemlist.Count;
}
}
public void CreateDBYDFolder()
{
NameSpace mapinamespace = outlook.GetNamespace("MAPI");
MAPIFolder defultemailfolder = mapinamespace.GetDefaultFolder(OlDefaultFolders.olFolderInbox);
defultemailfolder.Folders.Add(this.DBYDEmailFolderName, OlDefaultFolders.olFolderInbox);
}
namespace DBYD.Services.Outlook
public class Outlook
private Application outlook;
private Outlook(Application outlookInstance)
this.outlook = outlookInstance;
this.DBYDEmailFolderName = "DBYD";
public static Outlook ConnectToOutlook()
try
Application instance = new ApplicationClass();
return new Outlook(instance);
catch (System.Exception)
throw new ApplicationException("Could not connect to outlook");
public string CurrentUser
get
return this.outlook.GetNamespace("MAPI").CurrentUser.Name;
public bool HasDBYDFolder
get
return (this.DBYDFolder != null);
public int CountOfUnreadItems
get
var itemlist = this.DBYDFolder.Items.Restrict("[Unread] = true");
return itemlist.Count;
public void CreateDBYDFolder()
NameSpace mapinamespace = outlook.GetNamespace("MAPI");
MAPIFolder defultemailfolder = mapinamespace.GetDefaultFolder(OlDefaultFolders.olFolderInbox);
defultemailfolder.Folders.Add(this.DBYDEmailFolderName, OlDefaultFolders.olFolderInbox);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment