Pe

27

Tam

2012

18:52

Hampurilaisravintolassa

Mies meni hampurilaisravintolaan, ja tässä on hänen ja tiskin takana hääräävän myyjän vuoropuhelu:

- Ja mitäs teille?

- Mitäpä tässä, kiitos kysymästä.

- Tarkoitan siis, mitä te syötte?

- Purkkaa. Tästä on kyllä mennyt jo maku.

- Mutta mitä te tilaatte nyt?

- Hesaria ja Aku Ankkaa, mutta otan hampurilaisen.

- Selvä. Ja minkähän hampurilaisen?

- No se systeemi, jossa on pihvi ja kaksi kuorta. Pitäisi teidän täällä tietää.

- Syötkö täällä?

- Silloin tällöin.

- Öh... siis syötkö täällä nyt tällä hetkellä?

- Purkkaa edelleen, mutta maku on mennyt jo.

- Puhun tilaamastasi hampurilaisesta. Tuleeko se mukaan?

- Jos se tahtoo.

- Siis otatko mukaan?

- Tule vain jos haluat.

- Selkeä kysymys: syötkö tilaamasi ruoan täällä?

- Onko siellä tilaa? Ajattelin kyllä että tuolla pöydässä...

- Hyvä on. Saako laittaa kaikki mausteet?

- Jos ne mahtuu.

- Eli: kaikkia mausteita vai ei kaikkia mausteita?

- Joo... ei kanelia.

- Eipä sitä kyllä yleensä... no, kaikkia muita saa siis panna?

- No sepä oli aika hävytön kysymys. Lähden kyllä nyt pois.

To

26

Tam

2012

19:24

Vaalijono

Jono Helsingin pääpostitalon ennakkoäänestyspaikalla ei ollut yhtään eilistä lyhyempi. Pari sataa innokasta äänestäjää jonotti eilen kymmenien metrien pitkässä jonossa illalla kuuden aikaan. Nähtyäni tuon toivottoman letkan käännyin kannoillani ja päätin yrittää uudestaan seuraavana päivänä. Tänään jono ei ollut siis yhtään sen lyhyempi kuin eilenkään, mutta jäin kuitenkin seisomaan sen hännille. Yllätyksekseni jono eteni melkein kävelyvauhtia tai ainakin hidasta sellaista. Loppujen lopuksi koko äänestysoperaatio ei tainnut viedä kymmentä minuuttia kauempaa. Hitain vaihe oli henkilöllisyyden tarkastaminen äänestyslippua jätettäessä. Kirjekuorien liimaukset ja allekirjoitukset vaativat oman aikansa, mutta sekin vaihe sujui nopeasti. Jonottajat olisivat voineet hieman vielä nopeuttaa toimenpidettä ottamalla henkilöpaperit valmiiksi esille. Toisinaan hyvään vauhtiin päässyt eteneminen tyssäsi siihen, kun joku alkoi kaivaa ajokorttiaan takataskunsa lompakosta. Tällaisina talvikeleinä takataskulle ei pääse kovin helposti, kun paksu ja polviin asti ulottuva palttoo peittää persustan. Presidentinvaalit kiinnostavat kansalaisia ja äänestysinnokkuus on nähtävissä ja koettavissa vilkkaimpien äänestyspaikkojen pitkissä jonoissa. Sauli Niinistö sai kuitenkin yhden äänen lisää tänään. Jännittävän vaalin tulokset saadaan reilun viikon kuluttua.

Ke

25

Tam

2012

20:08

Outlook desktop alert

Microsoft Outlook is not just an email client application. This outstanding software can do lot more than checking my inbox. Outlook calendar is a must today in order to keep track of my appointments and meetings. Quick notes are easily saved in Outlook as well and all my contacts are stored and synchronized with my smartphone. Outlook comes with powerful programming capabilities. Visual Basic for Applications or just VBA enables endless possibilities to extend the features. While the application is running, it usually polls external mailboxes out on the net and eventually notifies of new mail. The Outlook.SyncObject is fired periodically and it starts multiple processes to keep user’s mailboxes, calendar and other information up-to-date.

I like to check the state of my net connection every now and then. If the connection gets broken, I’d like to have an alert to quickly repair the connection. I could have installed some standalone application to do this task, but I like to keep the number of installed software as low as possible. My Outlook is running in the background and I wondered whether I could use it to make periodical checks and notify me of any exceptions raised. I wrote a simple script and hooked the SyncObject to run it once in every hour. I got my script ready and it ran smoothly checking the connection every hour. The only problem was displaying the alert if something was wrong.

The script adds a new mailbox item each time the connection gets broken. The new item is unread by default drawing my attention if I happen to check the folder. The easy way to display an alert or so called desktop alert is to create a rule, which pops up an alert window when the rule meets the requirements I have set. Now, I only needed to run the rule right after adding a new item in the folder to invoke the alert. My script first hooks the SyncObject so that it runs my script when the synchronization starts.

Dim WithEvents mySync As Outlook.SyncObject

The next step is to start my synchronization object when Outlook starts up. Outlook supports multiple SyncObjects and each of them can have different settings, for example different time intervals to fire the synchronization. I only have one SyncObject defined, so I can rely on the index number 1 when querying the object from the collection.

Private Sub Application_Startup()
  Set mySync = Application.Session.SyncObjects.Item(1)
  mySync.Start
End Sub

Finally the SyncStart event is fired right after the synchronization has started. This function finds my special rule "myRule", which I want to run after checking the state of the connection.

Private Sub mySync_SyncStart()

  Dim ns As Outlook.NameSpace
  Dim myRule As Outlook.Rule
  
  Set ns = Application.GetNamespace("MAPI")
  Set myRule = ns.DefaultStore.GetRules.Item("myRule")
  Set myLogs = ns.Folders.Item("Outlook").Folders
    .Item("Logs")
  Set myItem = Application.CreateItem(olPostItem)
  
  If (connectionStatus = False) Then
    With myItem
      .Subject = "Problems with connection"
      .Importance = olImportanceHigh
      .UnRead = True
      .Move myLogs
    End With
    myRule.Execute False, myLogs, False,
      olRuleExecuteUnreadMessages
  End If

End Sub

If the connection is broken, then the script creates a new posting item and adds it into the Logs folder. The final step is to run the rule in Logs folder to find any unread items and if found, the rule then displays the desktop alert letting me know about problems with the connection.

Final words

Microsoft Oulook is an outstanding application with enormous features and functions. One can implement virtually anything with Outlook and using the powerful programming language these capabilities can be extended with no limits. Using the Outlook’s synchronization objects you can create a service, which is run periodically while the application is running. I use Outlook to check every hour some items on the Internet and found the application an excellent companion to complete this task.