Programming Office 365 Jump Start 2

In this series, I will talk about how to start programming with Office 365 in shortest investment of time. I assume my audience will be .NET developers who do not have prior knowledge of Office 365.

Prerequisite: Programming Office 365 Jump Start 1

Exchange Online

Microsoft released Exchange Web Services Managed API SDK for programming messaging solutions for Exchange Online. The SDK is a class library that you can reference in your application and use its methods to connect to Exchange Online and consume its services. Version 1.1 is available at http://bit.ly/z1EY06, but version 1.2 is soon to be released of which documentation can be found here: http://bit.ly/yHcqVE. After installing the SDK, an assembly is available at C:Program FilesMicrosoftExchangeWebServices1.1Microsoft.Exchange.WebServices.dll for accessing Email, Calendar, Tasks and Contacts hosted in the cloud.

Authenticating to Exchange Online

Using the SDK, authenticating to Exchange Online with admin username and password is fairly easy:

var exchange = new ExchangeService(ExchangeVersion.Exchange2010_SP1)
{
     Credentials = new System.Net.NetworkCredential()
     {
          UserName = "admin@mycompany.onmicrosoft.com",
          Password = "passw0rd!"
     }
};

exchange.AutodiscoverUrl(primaryUser, url => true);

If the user is already logged on to that domain, username and password are not required. Use exchange.UseDefaultCredentials = true instead.

Querying User Availability

Prior to scheduling an appointment among two or more attendees, it is better to check whether they are free/busy at that time. Otherwise, it may result in conflict with other appointments.

var attendees = new List<AttendeeInfo>
{
    new AttendeeInfo()
    {
        SmtpAddress = "attendee1@mycompany.onmicrosoft.com",
        AttendeeType = MeetingAttendeeType.Organizer
    },

    new AttendeeInfo()
    {
        SmtpAddress = "attendee2@mycompany.onmicrosoft.com",
        AttendeeType = MeetingAttendeeType.Required
    }
};

var results = exchange.GetUserAvailability(attendees,
     new TimeWindow(DateTime.Now, DateTime.Now.AddDays(3)),
     AvailabilityData.FreeBusyAndSuggestions);

The code above returns whole bunch of information on availability and suggestions (responsible flag for this was AvailabilityData.FreeBusyAndSuggestions) according to availability of the attendees for next three days. You can go ahead and explore by yourself various types of properties this method reveals, but let us take a look at how we can get access to the suggestions that it made:

foreach (var time in results.Suggestions.SelectMany(suggestion =>
     suggestion.TimeSuggestions))
{
     Console.WriteLine(time.MeetingTime + "t" + time.Quality);
}

It is also capable of calculating conflicts automatically and return as part of the TimeSuggestion object.

Creating an Appointment

Now that we have learned how to query user’s availability, let us pick up a suggested time and create an appointment:

var appointment = new Appointment(exchange)
{
     Subject = "Discuss Exchange migration",
     Body = "Let us find a migration process that will
              cause least downtime of the service.",
     Start = appointmentTime,
     End = appointmentTime.AddMinutes(30)
};

appointment.RequiredAttendees.Add(
    "attendee2@mycompany.onmicrosoft.com");

appointment.Save(); 

Sending an Email

The quality indicator of a good SDK is that it gives a solid object model and makes it fairly easy to consume services such as sending email while taking care of the underlying complexities associated with communications all by itself:

var email = new EmailMessage(exchange)
{
     Body = "Hello from my cool C# demo.",
     Subject = "Email by code"
};

email.Attachments.AddFileAttachment("c:\mypic.jpg");
email.ToRecipients.Add("user@mycompany.onmicrosoft.com");
email.Send();

Accessing Folders

In this example, we will get access to a folder and delete all its contents including sub-folders:

var folder = Folder.Bind(exchange,
    WellKnownFolderName.DeletedItems);

folder.Empty(DeleteMode.HardDelete, true);

If we wanted to search for folders that contain certain string, instead of well known folders, we can do so as well. First of all we have to decide our search criteria, then call ExchangeService’s FindFolders method, which takes a folder root to search from, search criteria (filter) and maximum how many folders we are interested in getting in return:

var filter = new SearchFilter.ContainsSubstring(
    FolderSchema.DisplayName, "Reports");

var results = exchange.FindFolders(
    WellKnownFolderName.MsgFolderRoot,
    filter, new FolderView(10));

foreach (var folder in results)
{
    Console.WriteLine(folder.DisplayName);
    // If we have three folders contain 'Reports', output:
    // Annual Reports
    // Monthly Reports
    // Report formats
}

Scheduling Out of Office

Let us schedule an Out of Office automatic reply starting from now for five days, which will send message to people at work only (Internal):

var oofSettings = new OofSettings
{
    InternalReply =
        new OofReply("Hi, thank you for your email, but I am
              out of office."),

    Duration = new TimeWindow(DateTime.Now,
                    DateTime.Now.AddDays(5)),
    State = OofState.Scheduled
};

exchange.SetUserOofSettings(
    "admin@mycompany.onmicrosoft.com", oofSettings);

Notification Streaming

Exchange Web Service SDK allows to listen for change notifications whether it’d be new email arrival, Free/Busy status changed, item created/deleted and so on. Let us see how we can listen for new email arrival:

var subscription = exchange.SubscribeToStreamingNotifications(
    new FolderId[] { WellKnownFolderName.Inbox },
    EventType.NewMail);

var connection = new StreamingSubscriptionConnection(exchange, 30);

connection.AddSubscription(subscription);
connection.OnNotificationEvent += (s, a) =>
    {
        foreach (var item in a.Events.Select(
             notification => notification as ItemEvent))
        {
            Console.WriteLine(string.Format(
                 "Type: {0}, ItemId: {1}",
                 item.EventType, item.ItemId.UniqueId));
        }
    };

connection.Open();

Streaming subscription connection does not allow to persist more than 30 minutes. In order to extend the period of listening time, you will have to subscribe to OnDisconnect event which will be fired upon timeout and then you can invoke connection.Open() once again to establish reconnection and keep listening to the subscribed events.
 

Conclusion

There are countless many things that you can do with the object model. I hope this post has enough exercises to get you started with Exchange Online programming.

Programming Office 365 Jump Start 1

In this series, I will talk about how to start programming with Office 365 in shortest investment of time. I assume my audience will be .NET developers who do not have prior knowledge of Office 365.

Programming Office 365 Jump Start 2

Office 365 Overview

Office 365, publicly made available on June 28, 2011, is a cloud hosted Software + Services offering from Microsoft that includes online versions (read: cloud hosted version) of Exchange Online, and Lync Online, SharePoint Online. Office Web Apps and Office Professional Plus are also included as per plan.

Office 365 is a complete business productivity solution which includes platforms such as SharePoint. Microsoft’s yearly revenue from SharePoint alone is nearly $2B, which gives us a glimpse of the magnitude of success SharePoint has managed to achieve in past 10 years. Because SharePoint is a web application platform, IT Pros and Devs around this industry comprise even bigger of an economics than just that. That also begs a question what is your worth as a developer if you have Office 365 or SharePoint skill in your bag? Office365

Microsoft Exchange is one of the most popular Email, Calendar and Contacts hosting choice for the enterprise. On the other hand, Microsoft Lync, which was formerly known as Microsoft Office Communication Server, is the biggest push from Microsoft to establish itself as an automatic choice in the Unified Communication space. Being the cloud citizen Office 365 offers additional addons to fulfill scaling needs as business grows or shrinks.

Office 365 Plans

As we have just mentioned earlier it is one size fits all, there are three plans to choose from:

  • Professional and small businesses
  • Midsize business and enterprises
  • Education

Enterprises enjoy an additional benefit though, which is being able to offer Office 365 to kiosk users. Some of the scenarios they may cover depending on of course how you use it are Timesheet entry, keep track of schedule on Calendar, Inventory, Request workflows and lookup policies.

Before your company or you decide to go for Office 365, which is as low as $6/user/month, you can always signup for a 30-day trial, which we will use throughout this series for our development work, too.

Full details about plans: http://bit.ly/yIly6l 
How you can deploy to private cloud: http://bit.ly/Aal6LR 
Cost estimator: http://tinyurl.com/78gk5r5

As soon as you have signed up for trial and activated, it gives you control over complete feature-set if you would have purchased a paid subscription as well:

Admin

You can administer everything very easily from this control panel, including user, services, subscriptions, licenses management, etc.

Office 365 Infrastructure Layer

It is hosted on Windows Azure, Microsoft’s cloud, administered via Windows Intune. Windows Intune is a cloud based update and security patches management solution via Web Browser, which by the way, we do not have to worry about, because it is done by Microsoft to keep their Azure infrastructure up-to-date. One of the key benefits of going cloud is that the infrastructure is free from maintenance at consumer level. On top of that, Microsoft guaranties financially backed 99.9% uptime of the service. Therefore, it offers ultimate reliability as well as enterprise-grade security. That said, Microsoft collects no data or put up ads, no document scanning for analytics/mining or improve their service, complete data portability and 5 layers of security: Data, Application, Host, Network and Physical.

All are hosted and configured to work right after your signup, so there is no deployment or configuration really is involved. Furthermore, you can access the same services across different form-factors, such as PC/Mac, Mobile: Windows Phone, Blackberry, iPhone, Android and Symbian. So, according to Forrester survey it came up about more than 300% ROI from Office 365.

Software + Services

Office 365 enjoys generic benefits of going cloud associated with it. However, as a developer you need to know how it is treated in the cloud. In the beginning I have mentioned that Office 365 is a cloud hosted Software + Services offering, before we look into that aspect, let us quickly recap some of the conventional hosting models that we are most familiar with.

Traditional

In traditional Client-Server system, there is a stack of servers for clients to connect over network or internet. As business grows, new servers are to be purchased and as business shrinks servers are needed to be offloaded.

Traditional Cloud/Software as-a Service (SaaS) model solves the problem with scaling up, out and down on business demand. Everything’s hosted in a cloud vendor’s datacenter. If it is Windows Azure, Microsoft has megastructures of datacenters across different continents of the world, which confirms nuclear-bomb-proof part of the cloud feature.

PreCloud

As you can see from the diagram, software is replaced with Cloud based SaaS websites which are accessibly via Web Browser, and rest of the client applications use On-premise servers, ie. locally hosted Lync, Exchange and SharePoint servers.

Software + Services offers best of both worlds, minus the need of network connectivity (managed hosting). Sure, you can use SaaS via Web Browser, but additionally, there are programmable API endpoints, which let Client Applications (App that you will write) to connect and consume services. In this case Exchange, Lync, and SharePoint Online.

S S

Your Apps live on the Client machines, enjoy the faster local data access and processing power, while syncing necessary selective data over the wire from/to the Cloud. These are the kind of apps that we will see how we can write in later posts in this series.

PinPoint: Office 365 Marketplace

Once you have built an app, it is time to go global. You can get yourself listed as vendor as well as your apps as products in the Office 365 Marketplace. Head over to http://pinpoint.com or for detailed guide: http://bit.ly/eMVqaf. Potential customers can then discover your apps and purchase from there, or perhaps even better contact your company for further customization or support. PinPoint allows your company to acquire global reach.

The ‘Web of Pain’ for Those Who Did Not Adopt Cloud Yet!

No one wants downtime. In this age of Web 2.0 (or even more), the usage of internet based applications has been redefined. People tend to engage themselves in much more volume than ever before, making it even harder for infrastructure guys to keep up the servers in full health. Server uptime is often one of the key factors for customer retention. Mashups built on top of open API based services are dependent on the health of the data source. For example, if Twitter is down, no Twitter-mashups may work without its own previously stored tweets. For complex, Line of Business and mission critical systems such as financial applications, availability is a vital aspect in success of the business. Whether the application is being served from on-premise servers or third party datacenters, there are numerous things that can go wrong and may directly impact availability.

TwitterOverCapacity

1. Web or Database server got corrupted

No wonder. It can happen. Anytime! There are various reasons as to why it may occur. You may have automatic Windows Updates turned on, and it got itself installed new patches that are not working so well with your software. You may have installed new software, hardware or driver for your newly installed hardware, weak firewall, Antivirus or Antispyware got failed, disk failure and many more. Security threats are up-to-date and intelligent, so if you do not regularly install Service Packs, fixes, this may result in to server crash too. The resolution may be reinstalling Windows and setting up all other applications necessary, which may lead to a really long downtime.

2. Hard disk failure

The single most important hardware in your server is probably the hard disk. You may have static resources cached in many places like RAM, Content Delivery Network, etc. However, dynamic queries like displaying list of items from inventory, getting a list of currently logged on user and so on, involve database. All kinds of databases store data in hard disk. File and database operations are more dependent on hard disk usage than other operations. Large and complex queries, even excessive calls to less complicated queries and file operations may be responsible for a relatively cheaper hard disk to get overheated, and hence turn itself down or get damaged. Hard disk failures are often hard to fix, costly and a big threat to application stability unless regular and proper backups were taken or there is no effective replication implemented in place.

3. Database replication is not easy

If your primary database server goes offline, you need a standby server that can serve requests almost instantly with complete and most current data. Replication ensures propagation of the update to the slaves, the primary server has just made. The slave then acknowledges, thus allows the sender to ripple the same through subsequent slaves. While distributed databases are not technically difficult to implement in local datacenter, performance-wise they are not the same since the machines are networked. On the other hand, to mitigate the situation of natural disasters, terrorist attacks, or such bring your datacenter down, you may want to have distributed datacenters in different continents across the globe.

4. Power Outages and Internet Cable-cuts

Information superhighways are super connected with each other. When a user hits your website, the request travels across several hops around the world to reach your server. Some of them may not have backup connectivity which may make your site unavailable to various parts of the world when they are down. Although, most well reputed hosting providers have connectivity to good backbones which also take care of decreasing the number of hops by intelligent routing, hence reducing chance of downtime. Power outages can happen in many ways and frequency of it varies in different countries. It is even harder for on-premise server environment to stay online without backup power generators. Both power and internet outages may occur very few times a year.

5. Server Monitoring is painful

There are so many things to look out regularly to ensure the servers stay in maximum health. You have to keep an eye on how it performs in extreme load, response/second to the requests over time, request execution time, disk read/write time, memory usage, CPU usage and so on. Although there are tools which can do this job for you, however, you still have to go through the logs and reports to find out what went wrong, when, and figure out possible reasons.

6. Architecting network is challenging

Network architecture for your internet application should be done well. To scale out you need more servers to be added to the system. The network architecture that can handle scalability, load balance the servers in harmony, keep network latency at minimum, replications requires network experts and visionary architects. Network latency directly affects user experience, so to keep it low, you may need to have datacenters established across the continents. A good architecture must have a door open for that too. Bad network architecture not only restricts you to flawlessly scale your business and present user with good experience, but also troubleshooting it can cause you sleepless nights.

7. Scaling is inconvenient

We, the programmers and architects may not always write code and design keeping scalability in mind. Even if we do, it often happens that userbase goes beyond expectation that the whole architecture requires to be redesigned, or the product finds less userbase than anticipated that most of the IT infrastructure stay underused, hence cause waste in operating cost. Both ways, scaling is a difficult decision to make. Whether we would like to scale up, down or out, it involves hundreds other technology and business criteria to be taken into consideration. Scaling does not happen right away as you have to have several meetings with IT department, business strategists, policy makers, etc. in your company to come an agreement.

8. More attention on infrastructure layer

The casualties take place in infrastructure layer distracts the whole company whether you are a developer or business executive and gets you put less attention to your work. You have a demo to a potential customer and your demo server stopped working right before it. This server is down, that server is up, but that functionality is not working, we are blocked on background services to run, this server has the wrong URL redirection – these are the most common sentences you hear in the morning and throughout the day in a company that uses IT.

In this post, I have shown 8 key pain points of traditional server systems. Hope this will give you a little glimpse of a few challenges of a living software.

Is Google a Major Software player?

All the Google fans out there, this is not a hatred post. I am a Google fan myself as well. This post is going to be informative, and an eye-opener to some people, because they have many misconceptions.

Google has an excellent branding strategy. For many people web is all about Google, while it’s not all wrong, except for social networking but definitely software is all web is wrong. Software is a huge market. Due to Google’s web branding general people tend to think Google is a major software player. This post is not going to be a hypothesis based/futuristic statements using Crystal balls (eg. Chrome OS will be a blast – they’re gonna be profitable), but rather facts, and valid logic with no biasness which I hope would reflect present software industry.

Head to Head

Please not another Microsoft vs. Google. Oh, come on now. If someone needs to be compared with, it obviously should be done against a model or standard. Microsoft is the first software company in the world, most successful as of now since its establishment 36 years ago, most revenue earning gigantic software company. And also I have worked with Microsoft and their tools for 13+ years and I know one or two things about them, it would be wise to compare two different entities on their products available in all verticals of software to establish whether Google is a major player in software industry or not based on impact in those verticals. Based on dominant visibility I will score 0 to 5. Just to make sure what it takes to be a giant, I’ll score Microsoft alongside.

Web & Cloud

Backed with Search & Ad, Google has a series of excellent products such as Google Maps, GMail, etc. Since they built almost flawless cloud for their products, they decided to put it up to the market. It works for many, but with less interoperability and lack of SLA, this makes a unsuitable option for most enterprises. (Have they started to offer SLA lately?) Who does business without SLA anyway? Not to mention they couldn’t beat Amazon, yet they have visibility in the cloud space.

Oh, one thing, we are not going to repeat the same product of it’s different flavors in other categories. For example, Google Maps has a variant in iPhone/Android and a desktop version. So, we are not going to mention those again in phone and desktop category.

Google’s web history is not all about successes, though. AFAIR, Buzz, Wave, Orkut, Knol, Lively utterly failed faster than the hypes were risen.

Google’s Score: 5. Microsoft’s score: 3 (Live Services + Azure – Bing – Ad, again Ad is the heart of web as of now).

Mobile

Android rocks, and there’s no doubt. It probably has equal market share of iOS, if not more. Microsoft is fighting hard with Windows Phone 7, really hard.

Google’s Score: 5. Microsoft’s score: 1.

Desktop

Which desktop software have you used lately from Google? Chrome and Picasa? That’s it? Both works really well in their categories. Chrome although has only 13% market share whereas IE (45%) and Firefox (30%), but its visible in the browser market. But, let’s not forget there’s a whole universe left in desktop business.

In order to indulge their urge to start something in desktop, they developed Chrome OS for years, and it is still not available to the masses, and everybody says on the internet that it’s way way too basic. I don’t even credit them for Chrome OS, since it is just another distribution of Ubuntu. Credit goes to the extremely hard working and passionate open source activists out there around the world. Sometimes I just don’t understand why a major player (for the sake of argument) in software takes 3+ years and still counting to complete one of the tiniest OSes for desktop given that the source is taken from ready-made Ubuntu!

We see no collaboration and communication, education, entertainment, music, science, media, finance, drivers, firmwares, classroom, digital typography, standards, runtimes (like Flash, Silverlight), biometrics/identity management, training simulation, AntiVirus, utility, backup, compression, multimedia authoring/editing software from Google. You name it. Google is totally absent in desktop.

Google’s Score: 0. Microsoft: 5.

Desktop publishing & multimedia authoring

“Use Microsoft’s Office Live (instead of Google Docs)” — don’t laugh at me. It was demonstrated as Chrome OS Office capability and recommended to use by that lead (forgot name, the chief scientist) of Chrome OS project. Why am I even talking about it? It has no better feature than 15 year old WordPad comes with Windows. There are strong competitors such as Zoho in online Office space. If you think you have ever thought Google Docs could replace Microsoft Word, Excel, OneNote, PowerPoint, Sharepoint, Project, Publisher, Visio, stop right here. You do not need to read this post any further. Let’s put a simple question here: what Google product would you use to produce professional grade publications (eg. Magazines)?

You want to be blown away, like right now? Try beta version of the next release of Office, Office 365 now!

Flash, Premier, After Effects, Fireworks, 3D Max, Maya, Microsoft’s Expression Design, Blend. I just cannot imagine how many decades it might take for Google to beat these wonderful tools. I have almost forgotten the wonderful line of DTP tools such as Photoshop, Illustrator, InDesign, Acrobat, Microsoft Expression Design. Google doesn’t even have a diagram (ie. UML) designing tool. For the magnitude of the market, I’d declare Google has no presence.

Google’s Score: 0. Microsoft: 5.

Server tools & Virtualization

Google has nothing to offer in Virtualization. For example, Microsoft offers Hyper-V, Virtual Desktop Infrastructure, Enterprise Desktop Virtualization. Google has no server OS/tools. Let’s take a look what’s possible in this landscape to name a few only from Microsoft:

  • Server OSes
  • Exchange Server
  • BizTalk Server
  • Commerce  Server
  • Groove Server
  • Project Server
  • Host Integration Server
  • ISA Server
  • Live Comm. Server
  • Office Comm. Server
  • Lync Server
  • Search Server
  • Sharepoint Server
  • Systems Management Server
  • Storage Server
  • Small Business Server
  • Home Server
  • Advanced Server

Google’s Score: 0. Microsoft: 5.

LoB

Google has nothing more than stack of Search, Maps, etc. in formal name Google Apps. There’s whole other universe is left in Google’s LoB offerings. Let’s forget about the major major vendors in this space, let’s consider only what Microsoft has to offer. Sorry, but I know much about Microsoft only.

  • Dynamics AX
  • Dynamics CRM
  • Azure Hosted Online CRM (forgot the name)
  • Dynamic GP
  • Dynamics NAV
  • Dynamics SL
  • Small Business Accounting
  • Microsoft Money
  • Small Business Manager Financials

Google’s Score: 0. Microsoft: 5.

Software Development tools and Database

Google is invisible here once again. Who uses GWT anyway? Until I can find an enormous community who use GWT, I’d say they are slightly visible. Forget those Java, PHP, Eclipse and other massive massive communities, let’s just see what Microsoft offers:

  • Visual Studio (C++, J#), unique languages = C#, F#, VB for web, desktop, cloud, mobile, VCS, Test, SDLC & Process Management, what not?!
  • Embedded programming tools
  • Robotics Studio
  • XNA Game Studio
  • Expression Studio

Google has no deployable database. They want your business data to store only on their cloud. The world has MySQL, SQL Server, Oracle, PostGre, SQLite and what not!

Google’s Score: 0. Microsoft: 5.

Entertainment and Gaming consoles

Google TV – although Intel have written 50% of their code, let’s still give Google 50% credit for their software. They are visible, but nowhere near Apple TV and Kinect. You can use Microsoft’s Kinect with your hand gestures, play Games and TV! Anyway, like Playstation, Microsoft’s XBOX, Google have nothing to offer to gaming consoles.. no gaming experiences whatsoever, forget Surface Computing.

Google’s Score: 1. Microsoft: 5.

Games

I have no statistics in my hands, but from my wild guess it could be 25% of the whole software industry. It’s that massive! We see Microsoft, Blizzard, Activision, EA, Nintendo, Sony, but there’s no Google.

Google’s Score: 0. Microsoft: 4.

Now, is Google a Major Software Player?

Total: Google = 11, Microsoft = 41 (of 45). That’s what the difference is. That’s what happens when you only focus particular verticals of the whole software market. Software market is complex. A company who develops and distributes/deploys software is a software company. Now the question is whether it is a major player or not. To be able to call one major, we should judge its appearance in the proper scale and right magnitude of the market itself. Even if I agree for the sake of argument that Google is a major player, which is clearly not, let’s take for example a report that ranks software companies worldwide according to revenue. As you can see Microsoft ranks #1 as usual and Google ranks #97 closely falls behind Kaspersky and Intel!. :-)

http://www.softwaretop100.org/global-software-top-100-edition-2010

Although I understand that the revenue not necessarily should come from direct sales, business is a complex ecosystem. Google earns a lot of its revenue from Search and Ad (discussed in web category), that’s why to establish its dominion over the software market overall, we have dissected what Google has to offer in various verticals of the industry and tried to judge its position. I am unfortunate to say that Google has barely any appearance except for in the web and mobile (2 of 9 categories), and is clearly not world’s major software player.