Outlook: Reply to HTML emails with plain text

Update: Alex remembered the add-in I ment: QuoteFix. Due to incompatibility issues with nowadays Outlook versions the guys published a VBA script doing mostly the same as the older add-in. Alex did some fine tuning on their script and applied parts of my snippet. Try his gist to get the best of both (mine and QuoteFix). Works like a charm for me.

When using Outlook to send/receive emails you usually press the reply (or reply all, forward) button to send back an answer. This works like a charm if the email you want to reply to was sent in plain text and you have the "line indention with prefix" option enabled in the Outlook settings.


Thus commenting the received email is pretty easy. Obviously there is no option to configure Outlook to reply to a HTML/RichText message with a plain text email too. So replying to such formatted mails with the "line indention with prefix" option enabled looks like this:


If you now try to write inline comments it is IMHO really hard for the recipient to find those in your reply. One might say: you can convert the reply message to plain text. Yes you can! But this won't convert the silly blue line into '>' prefixes. So I was looking for an add-in to solve this problem. I thought there was one I used in earlier Outlook versions, but couldn't find it anymore. After boongleing for an hour I decided to implement this using VBA. This is the result:

Enum AnswerType
    Forward = 0
    Reply = 1
    ReplyAll = 3
End Enum

Function DisplayPlainTextMessage(msg As MailItem, addPrefix As Boolean)
  Dim prefix As String
  If addPrefix = True Then prefix = "> "
  msg.BodyFormat = olFormatPlain
  Dim lines() As String
  lines = Strings.Split(msg.body, vbCrLf)
  Dim newBody As String
  For i = 0 To UBound(lines)
    If Trim(lines(i)) = "--" Then GoTo Break
    newBody = newBody & prefix & Trim(lines(i)) & vbCrLf
  msg.body = newBody
End Function

Function SendAsPlainText(how As AnswerType)
  On Error GoTo ErrorHandler

  Dim msg As Outlook.MailItem
  Set msg = GetMailItem

  If msg Is Nothing Then
    MsgBox ("No message selected.")
    GoTo ProgramExit
  End If
  Select Case how
    Case AnswerType.Forward
      Call DisplayPlainTextMessage(msg.Forward, msg.BodyFormat <> olFormatPlain)
    Case AnswerType.Reply
      Call DisplayPlainTextMessage(msg.Reply, msg.BodyFormat <> olFormatPlain)
    Case AnswerType.ReplyAll
      Call DisplayPlainTextMessage(msg.ReplyAll, msg.BodyFormat <> olFormatPlain)
  End Select

  Exit Function
  MsgBox Err.Number & " - " & Err.Description
  Resume ProgramExit
End Function

Sub ForwardAsPlainText()
  Call SendAsPlainText(AnswerType.Forward)
End Sub

Sub ReplyAsPlainText()
  Call SendAsPlainText(AnswerType.Reply)
End Sub

Sub ReplyAllAsPlainText()
  Call SendAsPlainText(AnswerType.ReplyAll)
End Sub

Function GetMailItem() As Outlook.MailItem

  On Error Resume Next

  Select Case TypeName(Application.ActiveWindow)
    Case "Explorer"

      If TypeName(ActiveExplorer.Selection.Item(1)) = "MailItem" Then
        Set GetMailItem = ActiveExplorer.Selection.Item(1)
      End If

    Case "Inspector"

      If TypeName(ActiveInspector.CurrentItem) = "MailItem" Then
        Set GetMailItem = ActiveInspector.CurrentItem
      End If
  End Select
  On Error GoTo 0
End Function

You can now modify your ribbon bar to add new buttons to the three subs ReplyAsPlainText, ReplyAllAsPlainText, ForwardAsPlainText:


Back in the early days of computer gaming one may remember the Comanche flight simulator. The simple 3D engine used for this and other games is based on a so called voxel rendering engine. Searching the Internet for this technique I found this nice article from Alex Champandard and this one from Codermind. Putting two and two together, again I paid attention to the WriteableBitmap class that is part of Silverlight 3.

To emphasize the .NET Open Space 2009 that is starting tomorrow here in Leipzig, I used a special background texture for the sky. Just press the start button and use W-A-S-D of your keyboard to fly around the terrain. I will clean up the sources after the upcoming and put it here on my blog. So stay tuned.


Fire with WriteableBitmap

Playing around with the new WriteableBitmap class in Silverlight 3 I remembered the time I started with VGA programming in assembler. After a quick research I found this simple algorithm to visualize the effect. I added the interactivity via mouse click and keyboard input to create new fire initiators.

The source is available for free: FireEffect.zip (12 kB)

Tunnel Effect with Silverlight

Another small sample using dynamic generated animations in Silverlight.

The source are available for free: TunnelAnimation.zip (7 kB)

Release of Silverlight Whiteboard


After a long run on a bumpy road our Trian.Whiteboard finally found it's way to the MSDN Code Gallery. Even if Microsoft Silverlight 3 is knocking on our doors this smart sample is a good start to get in touch with this technology. It shows how to use XAML to create a Rich Internet Application that communicates with a Windows Communication Foundation service in the background.

Check it out: http://code.msdn.microsoft.com/whiteboard
Play with it: http://playground.pixelplastic.de

.NET Bootcamp zu Silverlight und WPF

Am 20. März 2009 wird unter meiner Regie das dritte .NET Bootcamp der .NET User Group Leipzig stattfinden. Wie sollte es anders sein, geht es dabei um Microsoft Silverlight und die WPF. Die Registrierung ist ab heute aktiviert. Die Plätze sind limitiert, daher schnell anmelden. Falls ihr nicht wisst, was hinter den Bootcamps steckt und wie diese ablaufen, kann ich diesen Artikel von Torsten empfehlen.


A new sample about BezierSegment usage in Silverlight

You may know about the good old Windows screen safer Mystify. Thinking about my last post about the BezierCurve element I tried to rebuild this waving stroke animation. And here is the result:

Once again: feel free to download the sources.

Commenting your source is recommended and pretty helpful. But while implementing (e.g. SharpTM) most time it is annoying to scroll through all the big comment blocks. To get an overview of all class members it would be great to have the opportunity to collapse all comment blocks above all methods, properties, etc. That's why I tried to find a macro to do this - without success. So I wrote it by my own based on a region collapse macro I found here. And this is the modified function to do the job:

Public IsSummaryCommentsOutlineCollapsed As Dictionary(Of Document, Boolean) '' '' Toggling all <summary> comment blocks from collapsed to expanded outline. '' Please add [Imports System.Collections.Generic] on top of this module. '' Sub ToggleSummaryCommentsOutlineExpansion() If (DTE.ActiveDocument Is Nothing) Then Exit Sub End If If (DTE.UndoContext.IsOpen) Then DTE.UndoContext.Close() End If DTE.SuppressUI = True Try DTE.UndoContext.Open("ToggleSummaryCommentsOutline") Catch End Try If (IsSummaryCommentsOutlineCollapsed Is Nothing) Then IsSummaryCommentsOutlineCollapsed = New Dictionary(Of Document, Boolean) End If If (Not IsSummaryCommentsOutlineCollapsed.ContainsKey(DTE.ActiveDocument)) Then IsSummaryCommentsOutlineCollapsed.Add(DTE.ActiveDocument, False) End If Dim objSelection As TextSelection = DTE.ActiveDocument.Selection Dim line As Integer = objSelection.CurrentLine objSelection.StartOfDocument() ' find all <summary> blocks While objSelection.FindText("^:b*///:b*\<summary\>.*$", vsFindOptions.vsFindOptionsRegularExpression Or vsFindOptions.vsFindOptionsMatchInHiddenText) If (Not IsSummaryCommentsOutlineCollapsed.Item(DTE.ActiveDocument)) Then DTE.ExecuteCommand("Edit.ToggleOutliningExpansion") End If End While IsSummaryCommentsOutlineCollapsed.Item(DTE.ActiveDocument) = Not IsSummaryCommentsOutlineCollapsed.Item(DTE.ActiveDocument) objSelection.StartOfDocument() objSelection.GotoLine(line) DTE.UndoContext.Close() DTE.SuppressUI = False End Sub

In addition I just assigned a shortcut (Ctrl-M, C) to this macro to provide quick access while editing my sources.

Assign shortcut to Visual Studio macro

Update: Due to a comment of Torsten to add an undo option I implemented the support for toggling between collapsed and expanded mode and the undo functionality. Now running the ToggleSummaryCommentsOutlineExpansion function will collapse the first time for each document and toggles between expanded and collapsed mode each time you trigger this method.

First release of SharpTM

After I announced the SharpTM project on the discussion list of the TMAPI project in late October 2008 I now present a first alpha release of this .NET implementation of a Topic Maps engine. The current version 1.0.91 alpha 1 is just a library to be used in other projects. Hosting components like a console application, im- and export functionality and persistence solutions will be released soon. At all there are some more big issues like optimization to be solved. This first release was just an attempt to get a working implementation of a Topic Maps implementation in .NET that passes the TMAPI test cases from the TMAPI.Net project.

Feel free to check out the sources on the project homepage. Feedback is very welcome. If you want to support this project please contact me.

To get in touch with topic maps there are several articles to be found on the web:

For a long time I was looking for an elegant way to present my tons of pictures to friends and visitors of my blog. I played around with Silverlight to implement my own picture viewer, but wasn't happy with all my attempts. Last week I gave Deep Zoom a chance and now think that I found the right solution for my problem. You may have seen those fancy samples about the Deep Zoom technology like the Hard Rock Memorabilia. If you just don't know what Deep Zoom is I can recommend this presentation of Blaise Aguera y Arcas at TED.

Deep Zoom Composer - compose modeDeep Zoom Composer is a nice and handy tool to generate the tile patterns for each zoom level of a big image collection and to build up the so called sparse image scene graph with visual support. This graph contains the layout information (origin and scaling) of each image that is part of a Deep Zoom scene. Running the export process (3rd and last step) an XML file named SparseImageSceneGraph.xml will be produced. This is the source for the sparse image generation process that will create the tiles tree containing all the small image assets and an Deep Zoom Collection XML file (dzc_output.xml). The dzc_output.xml file in turn can be interpreted by a Silverlight application using the MultiScaleImage element to get access to all image tiles in the tree structure. That's the way Deep Zoom Composer works.

The problem and its solution

This process has a small problem for me. Looking at the large amount of pictures I've shoot since 2001 (around 30.000) it would be a hassle to manually arrange those (collection by collection) using the Deep Zoom Composer, where you have to drag & drop and scale each image on the surface. Okay there is the "Arrange in a Grid" feature that (in my opinion) does not result in a very eye-catching layout. That's why I came to the conclusion of writing a small .NET console application that will manage this issue for me in an automatic way. SparseImageSceneGenerator was born.

Compared to the process of Deep Zoom Composer this tool will help you to automate the composing process to generate the SparseImageSceneGraph.xml. The command line application only needs at least two arguments: a path to the location of your images and an output path to the resulting SparseImageSceneGraph.xml file. SparseImageSceneGenerator reads and analysis the properties of all images to create a nearly square shaped layout for all images. Before going into detail here is the result:

How it works in detail


(1) After reading all properties (size and metadata) of all pictures the sum and the square root of this sum for all aspect ratios will be calculated.


(2) The square root now limits the width of a rectangle where each image will be aligned row by row (including a cell padding between each image). In the figure above the sum of the aspect ratios of the two portrait images results in 1.333 (plus padding). The 3rd landscape image (AR = 1.5) does not fit into the row, because it will overflow the limit of 1.87 (plus padding). So it wraps to the next row. This generated grid now contains the final layout of all images.


(3) In a final step we have to adjust each rows width to be 1.0. This means scaling the width and origin of each image and row. That's it.

As you can see in the above sample the result is not a perfect square. It depends on the number of images. The more, the better (as you can see in the sample above). In addition SparseImageSceneGenerator supports the SparseImageTool that is part of the DZC installation to merge smoothly into the whole generation process. SparseImageTool is the command line version of the export process of DZC to create the final result based on the SparseImageSceneGraph.xml. The result is (as we know from the DZC export process) the dzc_output.xml file and the tree of tiles.


Feel free to download the current version and please give me feedback on this tool:

After Microsoft released the final version of Silverlight 2.0 last week I decided to update some of my samples I published before. Converting the Silverlight 2.0 Beta 2 based samples (physics attractor and the bending bezier curve) was straight forward without any problems. Instead the Silverlight 2.0 alpha based clock sample made some more work. That's why I decided to setup a new solution and start from scratch by rewriting the code behind files.

Feel free to download the source files:


Handling the BezierSegment as path in Silverlight

This small sample will show you the possibilities of Silverlights (and WPFs) BezierSegment class. To draw a bezier curve you have to encapsulate the BezierSegment as part of a Path element as shown in the following lines of code:

1 <Path x:Name="Curve" Stroke="#FFFFFFFF" StrokeThickness="2"> 2 <Path.Data> 3 <PathGeometry> 4 <PathGeometry.Figures> 5 <PathFigureCollection> 6 <PathFigure x:Name="Figure" StartPoint="27,56"> 7 <PathFigure.Segments> 8 <PathSegmentCollection> 9 <BezierSegment x:Name="Bezier" Point1="227,156" Point2="267,36" Point3="380,30" /> 10 </PathSegmentCollection> 11 </PathFigure.Segments> 12 </PathFigure> 13 </PathFigureCollection> 14 </PathGeometry.Figures> 15 </PathGeometry> 16 </Path.Data> 17 </Path> 18

The curve itself is rendered using four points: the StartPoint attribute of the PathFigure element and the three points Point1, Point2 and Point3 of the BezierSegment. Try to play around with this sample and feel free to have a look into the sources.

Get Microsoft Silverlight

Very simple Silverlight physics demo

This is the result of a 3h implementation of a simple physical sample. Each dot is attracted by the mouse cursor. So just move your mouse over the field to see the effect. The sources of this very small sample can be downloaded here.

Usability Thementag am 18. April in Leipzig

Benutzerfreundlichkeit ist zunehmend ein wichtiger Bestandteil heutiger Softwareentwicklungsprozesse. Sowohl für Desktop-Anwendungen als auch im Bereich des Web ist es notwendig den Endbenutzern eine intuitive Oberfläche zur Verfügung zu stellen, um effektiv und benutzerfreundlich mit dem Produkt arbeiten zu können. Dies spiegelt sich in einer höheren Produktivität beim Umgang mit der Anwendung wieder.

imageNeben technologieorientierten Lösungsansätzen, wird im ersten von drei Vorträgen im Allgemeinen auf Benutzerfreundlichkeit im alltäglichen Leben eingegangen. Weiter geht es mit Usability-Aspekten im Bereich des Web, gefolgt von einem Vortrag zu technischen Möglichkeiten mit der Windows Presentation Foundation (WPF) und Silverlight. Abgerundet wird dieser Tag mit einem 90minütigen Workshop, wo die gelernten WPF-Kenntnisse in einer kleinen Demo-Anwendung direkt am Rechner umgesetzt werden können.

Die Anmeldung erfolgt über eine E-Mail an anmeldung AT dotnet-leipzig DOT de mit Vorname, Nachnahme und dem Betreff "Usability". Die Teilnehmerzahl ist bzgl. des Workshops begrenzt. Gibt es mehr Anmeldungen als Plätze, entscheidet die Warteliste.

18.04.2008, 9:00 – 17:00 Uhr, Universität Leipzig (WiFa), Marschnerstraße 31, Raum 240.

Student Technology Conference 2008


location02Am 15. Mai 2008 ist es wieder soweit. Die alljährliche Konferenz für Studenten wird diesmal leider nur an einem Tag in Berlin stattfinden. Dafür aber kostenlos, wie ich dem Registrierungsformular entnehmen konnte. Die Teilnehmer können wie immer interessante Vorträge für IT Pros und .NET Entwickler erwarten.  Auch die angekündigte Location "Kalkscheune" macht einen netten Eindruck. Weitere Infos findet ihr unter www.studentconference.de.

Ich bin im Fernsehen

Naja. Mehr oder weniger im Fernsehen. Eigentlich "nur" im Internetfernsehen. Während meines dreitägigen Besuchs der Frankfurter Messe zur Microsoft Launch Tour 2008 letzte Woche wurde ich zusammen mit Grischa und Torsten von Lori interviewt. Dabei ging es um das kommende Referenzprojekt zu Visual Studio 2008 und .NET 3.5. Momentan arbeiten wir unter dem Codenamen Trian weiter an den Beispielen, die in naher Zukunft hoffentlich vielen Entwicklern zur Verfügung stehen werden. Aber seht und hört selbst, worum es dabei grob geht:


Zoomable ultra high resolution Silverlight clock

I like this nifty vector based scaling feature of Silverlight. That's why I was not often seen the last day and today. I developed a nice little clock based on one theme of the Clock Gadget of Windows Vista. Using Microsoft Expression Blend 2 December Preview and Visual Studio 2008 made it easy to get to the results.

But how to play with this toy: You can move the clock with a simple mouse drag and drop. For showing this cool effect of resizing I added the little white button on the top left of the clock. It's also just a drag and drop action on this button, to do the scaling of the clock. By pressing the Shift button while doing the resize movements you'll fix the aspect ratio of the clocks height and width. It's also possible to switch to full screen mode and back again by double clicking the background of this canvas.

The Visual Studio 2008 source of this smart application can be found here.

Download: Clock.zip

Simple billard game in Silverlight

After one day of trying and researching on Silverlight I implemented a simple game. My intention was to create a game that runs in fullscreen on a tablet PC including the usage of the stylus pen. I thought it could be pretty cool to build a billard table, because it feels like a real game, if you use the stylus as cue while playing with virtual balls. And here is the result.

For sure it's not that realistic, but it shows the features that Silverlight may afford for a new web experience. Another idea for a game project that matches this kind of gameplay could be a minigolf application. Hmmm. I can see myself staying in front of my lowered tablet while swinging a stick (with my attached stylus). ;-)

If you are interested in the sources of the billard game, you can download the xaml, js and html files here.

vom 21. bis 22. Mai 2007 im Landschaftspark Duisburg

Was gibt's neues in Sachen Software Architektur? Wie gestalte ich User Interfaces mit ordentlich User Experience? Und das nicht nur für Windows Anwendungen, sondern auch für's Web. Über diese Themen, bis hin zu Robotik und Spielprogrammierung mit XNA werden auf der diesjährigen STC im Vordergrund stehen. Bekannte Sprecher werden diese aktuellen Technologien der IT Industrie vorstellen. Dazu werden Workshops angeboten, um die neuen Technologien gleich mal ausprobieren zu können.

Neben den rein technologischen Aspekten bietet die Microsoft Student Technology Conference eine ideale Gelegenheit, namhaften Unternehmen kennenzulernen und Einstiegschancen bei diesen zu erhöhen. Zusätzlich wird im Rahmen der Konferenz das deutsche Finale des Technologiewettbewerbs Imagine Cup 2007 im Software Design ausgetragen!

2 voll gestopfte Tage, die man sich als Technologiebegeisterter nicht entgehen lassen sollte:

  • Technische Vorträge
  • Workshops
  • Imagine Cup ´07 Finale
  • Attraktives Rahmenprogramm
  • Abendveranstaltung
  • Vollverpflegung während der Konferenz
  • Kontakte zu anderen Studierenden, Sprechern und potentiellen Arbeitgebern
  • Und vieles mehr ...

Alle Infos findet ihr unter: http://www.studentconference.de/

Meldet euch am besten noch heute an! Anmeldungsschluss: 14. Mai 2007

BTW: Mich werdet ihr dort auch finden. :-)

New version of Microsoft's Silverlight

On Monday at the Mix '07 Microsoft presented a new alpha release of Silverlight 1.1 that comes up with pure .NET support. This cross-platform plug-in for browsers now includes a small core of the .NET framework, which allows developers to write managed code for web applications.

I'm going to check out, what the new features are and how these can improve the process of building applications for the web.

WPF/E becomes Microsoft Silverlight

Last weekend at the National Association of Broadcasters Microsoft announced Microsoft Silverlight to be the new "cross-platform, cross-browser plug-in for delivering the next generation of media experiences and rich interactive applications (RIAs) for the Web."

As I read there are no new features available with this announcement. The SDK is still the same as the Community Technology Preview (February 2007) release.

For more information look at: http://www.microsoft.com/silverlight/

Difference between WPF, WPF/E and XBAP

Getting closer to all the XAML stuff around the Windows Presentation Foundation I bumped into some understanding problems about all the new concepts. What are the meanings of all these shortcuts?


Stands for Windows Presentation Foundation (formerly known as Avalon) and is part of the new Microsoft .NET Framework 3.0 which is an extension to the existing .NET Framework 2.0. With WPF Microsoft relieves the older Windows Forms programming model and supports the software development process to be split into two different parts:

  • Design phase, where creative artists build the UI using Microsoft Expression or third party tools like Zam3D or Aurora;
  • Development phase, where the applications core functionality (business logic) will be implemented

The WPF team designed XAML (Extensible Application Markup Language) an XML-based scripting language to create user interfaces declaratively. The XAML markup is the interface between the design and implementation phases. The aforementioned designer products spit out XAML, that can be programmed through events and the underlying object model.


Means Windows Presentation Foundation Everywhere. It is a subset of WPF that only shares the XAML presentation layer. This means you won't have WPF controls (buttons, textbox, ...) or databinding support in WPF/E. Only the basic elements for graphics, event handling (using JavaScript) and media are available. The big advantage of this solution is that a visitor of your website doesn't have to install the whole .NET Framework 3.0 (54MB) on his client machine. WPF/E provides a cross platform option to enable XAML based content in different browsers. This is done shipping out plug-ins for common browsers like Mozilla Firefox, Internet Explorer 6+ and Apple's Safari. These add-ons are less than 2 MB, thus it is nearly the same size than Adobe's Flash Player plug-in. But regard WPF/E as being an extension for existing web technologies like ASP.NET, AJAX, PHP, ...

Today WPF/E is not in a final state, but will be finally released by mid-2007. In version 2.0 C# and VB.NET should be available, which will extend the current JavaScript support.


Stands for XAML Browser Applications. You maybe get to the conclusion, that this is equal to WPF/E. But there is a big difference. With XBAP you can provide a complete WPF application (without restrictions to the whole WPF functionality) to a client browser. The browser is the application host in this situation. Therefore the .NET Framework 3.0 has to be installed on the client side. You also have to ensure, that operations within your XBAP won't run into security problems on the client (e.g. file system access). This reflects the difference between a stand-alone WPF application and an XBAP: WPF applications run with the priveleges of the currently logged in user, whereas XBAPs are launched inside the browsers sandbox that has just a very small set of privileges. XBAPs and the security issues are pretty difficult. Maybe I can come closer to this in a future post.

In upcoming posts I'll step into more details about WPF/E, because I'm now looking for a new solution for combining my blog page and the flash based picture page.

backup lösung mit .NET 2.0

bereits vor einigen monaten hatte ich eine backup lösung vorgestellt. diese war javascript und rar basiert. um mehr bedienkomfort zu bieten, habe ich das ganze in einer .NET 2.0 anwendung umgesetzt. prinzipiell lassen sich wie bei der skriptbasierten variante inkrementelle sicherungen von dateien und verzeichnissen erstellen. dabei lassen sich die anzahl der inkrementellen backups einstellen, bevor ein neuer kompletter sicherungssatz begonnen wird. hier einige screenshots:

im moment sollte man die aktuelle version 1.0 (478,73 KB) noch als beta verwenden. für eventuellen datenverlust trage ich keine verantwortung. also vorher an unsensiblen daten testen. über anmerkungen zu bugs und mögliche featurewünsche würde ich mich freuen.