Exchange Web Services & Sending Inline Images on Exchange 2007 SP1

Microsoft recently released the Exchange Web Services Managed API SDK 1.0. This mouthful which I’ll just call EWSMAS is useful for writing custom applications that work with Exchange Server (2007 SP1 or 2010). In one of the projects we are currently working on, we need to send emails over Exchange with both normal attachments as well as inline in the mail body.

Now here’s the good thing – if you’re already on Exchange 2010, there is a simple property called IsInline that will allow you to specify the attachment as inline. However, if you’re on Exchange 2007 SP1 still (like in the case of Exchange Online/BPOS), you’re stuck as the property returns an exception stating it’s only for Exchange 2010. Here’s how to solve this problem. Note that I’ve created a simple console app to demonstrate this method only. I assume you know how to download the SDK and add reference to it in VS2008/2010.

   1:  ExchangeService service = 
   2:       new ExchangeService(ExchangeVersion.Exchange2007_SP1);
   3:   
   4:  // Use when machine is IN Domain
   5:  //service.UseDefaultCredentials = true;
   6:  //service.AutodiscoverUrl("user@domain.com");
   7:   
   8:  // Use when machine is NOT in Domain
   9:  service.Credentials = new WebCredentials("user@domain.com", "password");
  10:  service.Url = new Uri("https://Your-CAS-Server/EWS/Exchange.asmx");
  11:   
  12:  // Create an e-mail message and identify the Exchange service.
  13:  EmailMessage message = new EmailMessage(service);
  14:   
  15:  // Add properties to the e-mail message.
  16:  message.Subject = "Testing from .NET Client";
  17:   
  18:  // Add the image as inline attachment
  19:  FileAttachment attachment = 
  20:       message.Attachments.AddFileAttachment("C:\\temp\\attach.png");
  21:  attachment.ContentId = "01"; // this should be unique - say a GUID
  22:   
  23:  // Add the message body which refers to this contentID
  24:  message.Body = "Sent from a .NET with inline image <img src='cid:01'>";
  25:  message.Body.BodyType = BodyType.HTML;
  26:   
  27:  // Add recipeint
  28:  message.ToRecipients.Add("anotheruser@domain.com");
  29:   
  30:  // Send the e-mail message and save a copy.
  31:  message.SendAndSaveCopy();

Notes:

  1. Lines 5-6 should be used when the machine sending the mail is in the same AD domain as the Exchange server (say, an in-house Exchange server)
  2. Lines 9-10 should be used when the machine sending the mail is in a different AD domain from the Exchange server (say, hosted Exchange or BPOS)
  3. Line 21 is the one that sets a ContentId property for the image attachment – this will now NOT show the image as an attachment anymore. In case you need to simply add it again – this time without the ContentId.
  4. Line 24 uses this ContentId with the cid: property in a standard HTML image tag. This is what makes the image show up inline in the right place.

Inline 
This is what the inline image looks like once it is sent and received.


Tags: , ,
Categories: Development | Microsoft | Exchange

4 Comments
Actions: E-mail | Permalink | Comment RSSRSS comment feed

TechEd India 2010: PPTs, Demos & Code Snippets

I had two sessions at TechEd India 2010 – one on a lap around VS2010 Web and Cloud Development and the other on Lighting up Apps on Windows 7 using the Windows API Code Pack. The entire set of demos and content is given below. Please read to see how to use them.

The entire set is available on this SkyDrive folder. You can download the PPTs and demos for the ones you want. To create the demos yourself, you will also need to download the “Snippets” file and unzip it somewhere. Load these snippets into VS2010 using the Snippet Manager.

Open any of the projects and go through each “page” of code. You will see comments by me where you need to add some snippet. Simply type in the snippet and press tab twice to insert the appropriate code.


Tags: , , ,
Categories: ASP.NET | Development | Microsoft | Windows 7

1 Comments
Actions: E-mail | Permalink | Comment RSSRSS comment feed

Windows Phone 7 – My first app

As I unfortunately could not be at Mix 10 this year, I had to be content watching the Keynote from their live stream (which BTW worked flawlessly). Scott Guthrie as usual was outstanding and fun. And while showing off the new Windows Phone 7 developer tools went ahead and created a simple Twitter app on stage in about 5 minutes.

Well, I went ahead and downloaded the tools and installed them. Since I already had VS 2010 RC on my machine, it didn’t need to download the Express edition. It did install a bunch of other things and finally once done I went ahead and started it up.

So here’s how I beat ScottGu at his own game. I build a simple Twitter app for the Windows Phone 7 in even lesser time than him.

I created a Windows Phone application from the new project templates provided.WP7-01

Next, I changed some text around for the page and title. I also dropped in a TextBox, Button and a WebBrower control into the ContentGrid area on the phone.

WP7-02

WP7-03 I then simply added an event handler for the button’s click, like so:

webBrowser1.Navigate(new Uri("http://twitter.com/" + textBox1.Text));

That’s it. I then simply ran the application which started up the Windows Phone 7 emulator and deployed the application within it. Here’s what it looks like running.

The emulator doesn’t really have too many things in it other than Internet Explorer and some settings pages. You can of course go ahead and use the emulator to test out apps you create with Visual Studio 2010 or XNA Studio 4.0.

Here to creating great apps on Windows Phone 7. Have fun!


Tags: , ,
Categories: Development | Gadgets | Microsoft | Rave | SilverLight | Windows Phone

15 Comments
Actions: E-mail | Permalink | Comment RSSRSS comment feed

WebsiteSpark and What It Means

Yesterday Microsoft made an announcement that has extremely important implications if you are into Web application development. The WebsiteSpark program offers a ton of Microsoft software for free for web developers and web development companies that qualify. You get all these software for 3 years for both development and production usage. The list of software is:

  • 3 licenses of Visual Studio 2008 Professional Edition
  • 1 license of Expression Studio 3
  • 2 licenses of Expression Web 3
  • 4 processor licenses of Windows Web Server 2008 R2
  • 4 processor licenses of SQL Server 2008 Web Edition
  • DotNetPanel control panel

You can read more about the program on Scott Guthrie’s blog post and at the main site.

What I want to explore in this post is what it means for Web development in general. Currently, there is a trend or impression that if you need to create a software for a SME, you need to use the LAMP stack to remain competitive cost-wise. While true to some extent, what you do lose out is in terms of productivity and time-to-market with tools such as VS2008 and the Expression suite. But the cost of entry to use these has often been a pitfall to getting individual Web developers or smaller Web project companies as well as for the SME.

With WebsiteSpark this so-called “advantage” of the LAMP stack goes for a toss. Not only do you get all the tools you need for free for developing projects for SME companies you also get a number of other additional options that help ease your development, such as:

  • The Web Application Toolkits: A set of pre-packaged templates, samples, source code, etc. that can be simply plugged into your site to extend it with some extra features.
  • The Web Platform Installer: Allows you to quickly set up a developer or even production machine with not just the base requirements but also a number of free Web Applications such as WordPress, Umbraco, SugarDRM, DotNetNuke, Moodle etc. by simply following the setup prompts. Take a look at the Web Application Gallery and see how easy it is to setup these without having to mess around with configuration files and database connection settings on Windows.

This basically means that setting up and using Windows as a platform for Web application development not only is easier and faster but also is now available for free! You can also run most of the open source Web apps on Windows with better performance and scalability. So is there any real reason to still go for the LAMP stack? Try the above stuff out and then decide.


Tags: , , , ,
Categories: ASP.NET | Development | Internet | Microsoft | Rave

12 Comments
Actions: E-mail | Permalink | Comment RSSRSS comment feed

Windows 7 RTM – Smooth Install from USB Drive

Once it finally hit MSDN Subscriptions, I downloaded Windows 7 and went around installing it. One of the things I did differently this time is that instead of burning the ISO to a DVD and then booting my machine off it, I created a USB drive based install following these steps:

  1. Plug in your USB drive (thumb, hard disk, etc.). Must be >= 4GB in size
  2. Open a Command Prompt with Admin rights and run the following commands:
    • DISKPART
    • list disk [This will show a list of disks attached to your system. Note the # for the USB drive]
    • select disk # [where # is the number of the USB drive selected above]
    • clean
    • create partition primary
    • active
    • format fs=ntfs quick
    • assign
    • exit
  3. Now mount your ISO or open it with WinRAR and copy all the contents from it to the new drive partition
  4. Use the USB to boot your machine (if your BIOS supports it) and start the installation

On my 3 year old notebook, the complete installation off the USB drive took just about 18 minutes from start to finish. I highly recommend that you use this technique to get up and running with Windows 7 fast.

Every single device on my machine was detected and drivers installed automatically. It also found the latest official nVidia drivers for my video card from Microsoft Update and downloaded them and installed too. I had a fully working machine in about 30 minutes and have started installing all the software I need. Kudos to the Windows team on getting this so right this time.


Tags: , ,
Categories: Microsoft | Tips | Windows 7 | Rave

5 Comments
Actions: E-mail | Permalink | Comment RSSRSS comment feed

GoI E-Gov Policy – Open Standards or Open Source?

The Government of India (GoI) has been lately revising a Draft Policy on E-Governance – which is all well and good. However, a number of clauses in this are quite concerning – especially the ambiguity and general mix-up between what is called “Open Standards” and “Open Source”.

More...


Tags: , ,
Categories: Linux | Microsoft | Rant | Government

6 Comments
Actions: E-mail | Permalink | Comment RSSRSS comment feed

Tech Crystal Ball 2009

As the year is truly under way now, here are a few predictions I can think of in the technology world that is going to happen this year.

Hardware/Gadgets become cheaper and more powerful

We’ve seen this happen the last couple of years – with dual, quad and now oct-core systems readily available. Devices such as high end mobiles are also becoming quite popular as are Netbooks and LCD TVs. All of these will continue to grow as well as becoming more affordable – both to beat the recession as well as due to innovations in this area.

Hosted Paid Services or Pay-Per-Use Model becomes more popular

Most small to medium companies will start finding value in using hosted services for many of their IT infrastructure requirements rather than doing it all themselves. Hosted Exchange, SharePoint and CRM are going to take off this year in a large way – even in India. (Believe me, I recently moved to this model and it’s not just cheaper, it’s much lesser headache to manage.)

The Pay-Per-Use model will also catch on – for services that are required on a less frequent use basis. For instance, in companies that do not require all the high-end features of Office installed on every desktop, it might make a lot of sense to have a PPU model for certain advanced tasks that can be used as and when required by designated people.

Online Storage Balloons Up

Currently you get a good 5-25 GB in most online storage areas – however I see this to grow to the range of 100-250GB this year for free storage and practically unlimited for paying customers. Everything – documents, photos, music and movies will be allowed to sync back to the “cloud” as it were.

Corollary: Optical Media Starts to go away

As the online storage area heats up, I predict that the requirement for offline optical media will go away – may not happen completely this year – but this year will be that start to the end of optical media.

FOSS vs. Microsoft – the war continues

We won’t see a real respite from the FOSS/MS war. The FOSS camp is going to play the “free” card in these recession times to a lot of people, while MS will need to pull up their socks and show a more cautious approach to handling sales of their products. The PPU and Hosted models will be a great help to them in this war. MS of course has a number of products in the pipeline that can make a huge difference. FOSS does have its own set of drawbacks – like stagnating product lines (OpenOffice for e.g.) and TCO for subscription based supports being higher than MS costs. Both sets will need to offer much better value proposition to customers.

Microsoft - Winners: Windows 7, Office 14, Visual Studio 2010

Windows 7 is going to be the big hype product of the year. The “mistakes” of Vista are hopefully soon going to be forgotten with the pre-beta and the leaked beta already getting excellent reviews. If MS pushes it out this year especially giving a better value proposition including hyping cost savings thanks to “GREEN” systems, it will have a sure-fire winner in it’s hands.

Office 14 hasn’t got too much coverage – but a web-based version – with almost all the features makes perfect sense for the PPU/Hosted model and can help drive up adoption. We’ve yet to see other features that make it into this release, though.

Microsoft – Losing Ground: Windows Mobile, Internet Explorer

I predict that WM and IE will continue to lose ground to others – unless MS does something very, very innovative in both of them. WM is a great platform for business users. However, the interface clunkiness as well as long time gaps between updates don’t let it really go the way it should.

Internet Explorer 8 is right round the corner and is a great browser. But I still feel that there is so much more that it could have done than Web Slices and Accelerators. Hopefully it won’t be plagued with bugs once it comes out.

GREEN Computing

A lot of companies are going to go GREEN – it terms of energy efficiency of their infrastructure. Both hardware and software can help this out tremendously. Vista and Win7’s “sleep” functionality, Hyper-V based server consolidation, efficient cooling and other technologies will become part of mainstream and recommended to use.

All-in-all, this year will have its own ups-and-downs. These are my (current) predictions. I might revisit them 6 months down and see if there are any changes I think that might happen. Here’s wishing you a Happy, Prosperous, Productive and Safe New Year 2009.


Tags: , , , ,
Categories: Microsoft | Windows 7 | Windows Vista | Internet | Gadgets

8 Comments
Actions: E-mail | Permalink | Comment RSSRSS comment feed

A great time to be a Computer Science student in India

As is usual to a slightly long post, I start with a bit of historical context. In the days back when I was a student in school, computers were a fairly new thing. I was lucky to have started early on BBC Micros and having access to the Internet waaaay before most people had heard of it thanks to growing up in one of India’s premier universities. In school, our PCs, PC-XTs and PC-ATs were major drool points for us geeks.

However, software was another issue. A few of us loved programming – but access to software was fairly impossible. Getting Turbo Pascal and Turbo C++ was quite difficult and it was usually from a (friend-of-a-friend)^n from where we would (ahem) make copies to try out our pieces of code. I remember writing (literally) entire programs on sheets of paper with dry run notations on the side for each variable for each pass and then go type it out in school to try out some new stuff that I had “created”.

These days however, access to software is much easier. Unfortunately, professional quality software is usually quite expensive and for a student in India, typically out of their budget. This is where Microsoft’s recently announced DreamSpark initiative comes to their rescue.

DreamSpark allows students in India to download or get a DVD of most of the Microsoft programming and designing stack for FREE! All a student needs to do is register at the site, get their student status verified and they can get access to the free download and go and simply pick up the free DVD from any of the over 200 locations in India and start using it.

And what is it that they get for free? The list includes:

  • Windows Server 2003 Standard
  • Visual Studio 2008 Professional
  • Visual Studio 2005 Professional
  • SQL Server 2005 Developer
  • Expression Studio
  • XNA Game Studio 2.0

Remember that these are FULL versions of these products, without any restrictions (time or uses) for FREE.

This means that computer science students can now start working with professional level tools right from the start. Also, if anybody uses the “Open Source is best for learning programming” argument, this is no longer true. The Microsoft programming stack is so much more productive and now is accessible by any student in India and all for free to. I wish this was available to me when I was in school too.


Tags: ,
Categories: Development | Internet | Microsoft | Rave | SQL Server

31 Comments
Actions: E-mail | Permalink | Comment RSSRSS comment feed

Windows Live Mesh for Mobile

Live mesh is a great service that lets you sync devices or store it online from where you can access them from anywhere. It’s currently available as a tech preview and if you’re signed up you can sync multiple devices across.

Finally, the team has released Live Mesh for mobiles as well. Currently it support Windows Mobile 6.x. However you will not be able to access this from the usual places – that is, by either going to http://m.mesh.com or by logging into your Mesh Desktop and trying to add a device. You need to go to https://www.mesh.com/Web/MobileDownload.aspx and follow the onscreen instructions to download the installer (.CAB). You can then connect your WM device and install the software through ActiveSync/WMDC.


Tags: ,
Categories: Gadgets | Internet | Microsoft | Windows Live

15 Comments
Actions: E-mail | Permalink | Comment RSSRSS comment feed

I'm a PC - and proud of it

I always found the Apple "I'm a Mac/I'm a PC" ads funny when I saw them - but not for the reasons that Apple thought. Their claims were fairly weird considering > 95% of the world uses PCs with Windows. and not only that, the PCs come in a gazillion different combinations with another gazillion types of hardware and software setups. Whereas Apple has complete control over the hardware and the software that gets installed on their machines - so making their systems work is the least they can do.

 The PC (and by this I mean the generic PC combination whether it be desktops or notebooks + Windows) is a much, much more versatile device and can do so much more. And finally Microsoft is showing people the true story with their new ads. The video ads show people from normal walks of life and some celebrities - all who use PCs for a huge number of varied tasks - showing the true power of the PC. And combined with the Windows Mobile platform (for PDA/SmartPhones) and Windows Live (for services on the 'Net), the PC is at a much more powerful stage than it ever was.

The best part is that you can upload your own videos as well to say how you have been using your PC and how it has affected your life, work and personal way of working. Think of this as a way to show your appreciation for this system.


Tags: , ,
Categories: Internet | Microsoft | Rave | Windows Live

6 Comments
Actions: E-mail | Permalink | Comment RSSRSS comment feed