Skip navigation.
Half-baked opinions, served lukewarm.
weed's picture

The MS Way

Matt,

Try this:

  1. Copy the following into a file and name it 'launchvim.vbs'
    Option Explicit
    
    Private Sub launch()
    
          Const TemporaryFolder = 2
    
          Dim ws, ol, insp, item, body, fso, tempfile, tfolder, tname, tfile
    
          Set ol = CreateObject("Outlook.Application")
    
          Set insp = ol.ActiveInspector
          If insp Is Nothing then
                Exit Sub
          End if
          Set item = insp.CurrentItem
          If item Is Nothing then
                Exit Sub
          End if
    
          body = CStr(item.Body)
    
          Set fso = CreateObject("Scripting.FileSystemObject")
          Set tfolder = fso.GetSpecialFolder(TemporaryFolder)
          tname = fso.GetTempName
          Set tfile = tfolder.CreateTextFile(tname)
          tfile.Write( Replace( body, Chr(13) & Chr(10), Chr(10) ) )
          tfile.Close()
    
          Set ws = WScript.CreateObject("WScript.Shell")
          Wsh.Echo( "c:\vim\vim62\gvim.exe " & tfolder.Path & "\" & tname )
          ws.Run "c:\vim\vim62\gvim.exe " & tfolder.Path & "\" & tname ,4, true
    
          Set tfile = fso.OpenTextFile(tfolder.Path & "\" & tname, 1 )
          item.body = Replace( tfile.ReadAll, Chr(10), Chr(13) & Chr(10) )
          tfile.close()
    
          fso.DeleteFile( tfolder.Path & "\" & tname )
    
    End Sub
    
    Call launch()
    
    
  2. In Outlook, Go To Tools->Macros->VB Editor (Make sure your Security settings for Outlook are set to Medium)
  3. Add a new module, and paste this into it
    Sub LaunchVIM()
    
        Dim windir As String
    
        windir = Environ("WinDir")
    
        Shell (windir & "\system32\cscript.exe " & windir & "\system32\launchvim.vbs")
    
    End Sub
    
    
  4. Open a new Outlook mail message
  5. Click View->Toolbars->Customize
  6. Under the Commands tab, Select Macros on the left, and drag the macro you just created to the Outlook toolbar in your newly opened mail dialog.
Voila! Now you can launch vim from the Outlook toolbar!

EDIT by matthew: cleaned up formatting for slightly easier readability.

Reply

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <b> <i> <li> <ol> <ul> <p> <pre> <br> <blockquote> <hr> <img> <h1> <h2> <h3> <strong> <font> <div>
  • Web and e-mail addresses are automatically converted into links.
  • Lines and paragraphs break automatically.
More information about formatting options Captcha Image: you will need to recognize the text in it.
Please type in the letters/numbers that are shown in the image above.