About

Tanzim Saqib is a .NET Architect consultant, who won Microsoft “Most Valuable Professional” award couple times. He helped British Telecom build Web 2.0 for Business SaaS architectures complex widget ecosystem, hybrid MVC, and CMS Framework for their 3.5M customer-base. He was awarded Microsoft “MVP” for exceptional technical contribution and leadership in the community.

In 7 years in professional software development, he worked for companies like personalized Web 2.0 start-page Pageflakes, Vancouver based Sitemasher, a SaaS CMS platform and .NET controls developer Telerik. In addition, he developed many applications for ranging from financial institutions to university automation system. He is an open source activist and technology speaker. He holds a bachelor degree in Computer Science & Software Engineering.

Contact

Email: me at FirstnameLastname dot com | Facebook | Twitter: TanzimSaqib | LinkedIn. He is unavailable for consulting at the moment.

Interests

While he is not jamming with the latest technologies, he contributes to open source projects, writes articles for the community, and blogs.  He currently lives in Bangladesh, and able to move anywhere on professional demand. He loves Food-o-graphy, photography as well as Lomography.

Experience

Huge line of experience summarized above. Should you need in detail, please send him an email.

Technical Book Reviews

He officially reviewed and ensured technical correctness of the book, LINQ to Objects using C# 4.0 by Addison-Wesley Professional.

Source Available/Open Source projects

He created the following source available projects:

NoBrainer: It is an MVC + CMS Framework, as its name suggests for low-fi developers and savvy business stakeholders. It provides developers the flexibility of MVC as well as the control of WebForm, resulting in a testable and content manageable WebForm infrastructure for you application. NoBrainer currently supports only Web at the launch, however it can easily be extended to work with Desktop as well as Mobile. That way your logic and test code remain the same across different UI layers.

News Framework: News Framework is an open source offline news reading framework on which any RSS based news website can have its own Windows Phone 7 application in just minutes. The configuration, content and styles can be managed from outside of the framework itself to fit the needs.

Cassini 4.0: Cassini is now an open source, portable and redistributable web server. This light-weight Microsoft’s source available web server is used to be shipped with Visual Studio as integrated development server. Saqib has revived Cassini in version 4.0 with many new features.

MyStream: He is the creator of the first lifestreaming portal framework in ASP.NET 4.0, MyStream. Lifestream is a time ordered stream of activities, that functions as a diary of your electronic “social” life. In this Web 2.0 era, you get to use Twitter, Facebook, Delicious, Flickr, write blog posts, keep your friends up to date, and you are curious about what your friends are up to, too. Read on how it was built.

Open source projects that he contributed to: Dropthings and AspectF.

Public Speaking

Saqib is a technology speaker. He spoke on :

Technical Articles

Parallelizing Windows Applications in .NET 4.0
Published: May 6, 2010

Social Lifestreaming with ASP.NET 4.0
Published: August 2009
Awarded “Article of the month August 2009 in C# category” by readers’ votes.
Awarded “Article of the month August 2009 in overall category” by readers’ votes.

DropZone: A Database-less Secured File Storage using OpenID
Published: June 2009

Building ASP.NET applications for Windows Azure
Published: November 2008

Cloudship: ASP.NET Membership Provider for the Cloud
Published: November 2008

7 ways to do Performance Optimization of an ASP.NET 3.5 Web 2.0 portal
Published: February 2008

Client-side Best Practices
Published: January 2008

Building a Volta Control : A Flickr Widget
Published: January 2008

Imagine Cup 2011

He was one of the judges of Imagine Cup 2011 Bangladesh, and traveled with the team, first ever to participate from Bangladesh, as a Technical Advisor to New York for the World Finals. The team won People’s Choice Award.

ACM Problemsetting

Saqib is the youngest problemsetter of very prestigious ACM UVa Online Programming Contest. He set this Number Theory based problem “Mr. Azad and his son!!!!!” when he was only 18.

Recent Posts

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 Files\Microsoft\Exchange\WebServices\1.1\Microsoft.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.

  1. Programming Office 365 Jump Start 1 2 Replies
  2. Windows Phone 7.5 Apps In Record Time Leave a reply
  3. Installing Bangla in Android 2 Replies
  4. NoBrainer: My New Open Source project 11 Replies