Skip to content

Commit

Permalink
Version 8.0
Browse files Browse the repository at this point in the history
New Features
------------
- When preparing to edit an email in Vim, OutlookVim.bas will query the Vim instance checking to see if multibyte support is enabled in Vim.  It does this by checking to see if a bomb is enabled (:set bomb) and the value of fileencodings (:set fileencodings) to see if ucs-bom or any utf strings have been specified.  If multibyte is enabled, then the file created by OutlookVim.bas will be saved in unicode.  If your Vim is not setup to edit unicode files, Outlook will not enable the unicode format.
  • Loading branch information
dfishburn authored and vim-scripts committed Feb 9, 2013
1 parent fde92ef commit c3e4ebc
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 28 deletions.
12 changes: 8 additions & 4 deletions README
Expand Up @@ -4,7 +4,10 @@ For Windows users, this plugin will allow you to add a button in Microsoft Outlo

The filetype of the buffer is automatically set to "mail". This allows you to use all of Vim's great plugins and editing features to alter the email and customize the buffer using Vim's standard filetype support. When finished, simply saving the file will automatically update the body of the email in Microsoft Outlook.

This has been tested with Outlook 2003 (WinXP SP3) and Outlook 2007 (Windows 7 64bit and 32bit).
This has been tested with:
Outlook 2003 (WinXP SP3)
Outlook 2007 (Windows 7 64bit and 32bit)
Outlook 2010 (Windows 7 64bit and 32bit)

There are a number of preferences you can set within the plugin to customize it for your use.
These settings can be explored here:
Expand All @@ -15,10 +18,11 @@ Installation instructions for Outlook can be found here:
:h outlook-macro
:h outlook.txt

NOTE: All code is included in these files. There are no executables you need to run on your system. For those interested, the documentation outlines how Vim and Outlook communicate with each other.
NOTE: All code is included in these files. There are no executable files you need to run on your system. For those interested, the documentation outlines how Vim and Outlook communicate with each other.

Please use the VimWiki (link at top of page) to post comments and suggestions.
I routinely monitor the vim_use group.
If your Vim is Unicode enabled (:set bomb? fileencodings?), you will be able to edit emails which contain Unicode characters. See the help file for more details.

Please use the vim_use group to post comments and suggestions.



25 changes: 21 additions & 4 deletions doc/outlook.txt
@@ -1,18 +1,18 @@
*outlook.txt* For Vim version 7.0. Last change: 2012 Oct 09
*outlook.txt* For Vim version 7.0. Last change: 2013 Feb 01


VIM REFERENCE MANUAL
by
David Fishburn <dfishburn dot vim at gmail dot com>

Outlook Vim Plugin
outlook.vim version 7.0
outlook.vim version 8.0

For instructions on installing this file, type
:help add-local-help
|add-local-help| inside Vim.

Homepage: http://vim.sourceforge.net/script.php?script_id=3087
Homepage: http://www.vim.org/scripts/script.php?script_id=3087

*outlook*
*outlookvim*
Expand Down Expand Up @@ -76,6 +76,19 @@ David Fishburn
==============================================================================
2. What's New *outlook-new*

Version 8.0

New Features
------------
- When preparing to edit an email in Vim, OutlookVim.bas will query the
Vim instance checking to see if multibyte support is enabled in Vim.
It does this by checking to see if a bomb is enabled (:set bomb)
and the value of fileencodings (:set fileencodings) to see if ucs-bom or
any utf strings have been specified. If multibyte is enabled, then the
file created by OutlookVim.bas will be saved in unicode. If your Vim is
not setup to edit unicode files, Outlook will not enable the unicode format.


Version 7.0

New Features
Expand Down Expand Up @@ -202,11 +215,15 @@ Version 1.0
started.
- See step 16 below.
2. From the menu Tools->Macro->Visual Basic Editor (or Alt-F11)
- For Outlook 2010, I had to restart Outlook with Admin rights
by holding down CTRL-SHIFT when I clicked on the Outlook icon.
3. From the menu File->Import File (or Ctrl-M)
4. Choose the file ...\vimfiles\plugin\OutlookVim.bas (where ever you
installed the plugin).
5. Expand the Modules folder in the Project pane
6. Right click on Module1 and choose Project Properties
- Right click on Module1 and choose Project Properties (if available)
6. You may have to click on the top level folder (VbaProject.OTM)
- Right click on Module1 and choose Project Properties (if available)
7. Change the project name to "Vim"
8. Change the project description to "Edit emails with Vim"
9. From the menu File->Save (or Ctrl-S)
Expand Down
72 changes: 61 additions & 11 deletions plugin/OutlookVim.bas
@@ -1,9 +1,9 @@
' OutlookVim.bas - Edit emails using Vim from Outlook
' ---------------------------------------------------------------
' Version: 7.0
' Version: 8.0
' Authors: David Fishburn <dfishburn dot vim at gmail dot com>
' Last Modified: 2012 Sep 25
' Homepage: http://vim.sourceforge.net/script.php?script_id=???
' Last Modified: 2013 Jan 10
' Homepage: http://www.vim.org/scripts/script.php?script_id=3087
'
' This VBScript should be installed as a macro inside of Microsoft Outlook.
' It will create two files and ask Vim to edit the file (body of the email)
Expand Down Expand Up @@ -96,9 +96,12 @@ Sub Edit()


Dim ol, insp, item, fso, tempfile, tfolder, tname, tfile, cfile, entryID, appRef, x, index
Dim startAt, allOccurrences
Dim Vim, vimKeys, vimResponse, vimServerName
Dim overwrite As Boolean, unicode As Boolean

startAt = 1
allOccurrences = -1
' MsgBox ("Just starting LaunchVim")

Set ol = Application
Expand Down Expand Up @@ -162,6 +165,22 @@ Sub Edit()
End If
End If

vimResponse = Vim.Eval("match(&fileencodings, '\<ucs-bom\|utf\>')")
If vimResponse > -1 Then
' If the users Vim instance has encoding which support
' mulibyte characters, turn on unicode support by default
unicode = True
' MsgBox ("OutlookVim: Enabling unicode support due to global fileencodings")
End If

vimResponse = Vim.Eval("&bomb == 1")
If vimResponse = 1 Then
' If the users Vim instance has :set bomb, turn on unicode
' support by default
unicode = True
' MsgBox ("OutlookVim: Enabling unicode support due to enabled bomb")
End If

Set fso = CreateObject("Scripting.FileSystemObject")
If Err.Number <> 0 Then
MsgBox ("OutlookVim: Could not create a file system object." & vbCrLf & _
Expand Down Expand Up @@ -189,15 +208,46 @@ Sub Edit()
End If

Set tfile = tfolder.CreateTextFile(tname, overwrite, unicode)
If Err.Number <> 0 Then
' Clear Err object fields.
' Err.Clear
MsgBox ("OutlookVim: Could not create email file [" & tfolder.ShortPath & "\" & tname & "] " & vbCrLf & Err.Number & ":" & Err.Description)
tfile.Close
fso.DeleteFile (tfolder.ShortPath & "\" & tname)
' Quit will close Outlook
' Quit
Exit Sub
End If
' MsgBox ("Created body file:" & tfile.Name)

tfile.Write (Replace(item.body, Chr(13) & Chr(10), Chr(10)))
' Parameters
' Expression
' Type: System.String
' Required. String expression containing substring to replace.
' Find
' Type: System.String
' Required. Substring being searched for.
' Replacement
' Type: System.String
' Required. Replacement substring.
' Start
' Type: System.Int32
' Optional. Position within Expression that starts a substring used for replacement. The return value of Replace is a string that begins at Start, with appropriate substitutions. If omitted, 1 is assumed.
' Count
' Type: System.Int32
' Optional. Number of substring substitutions to perform. If omitted, the default value is –1, which means "make all possible substitutions."
' Compare
' Type: Microsoft.VisualBasic.CompareMethod
' Optional. Numeric value indicating the kind of comparison to use when evaluating substrings. See Settings for values.
' tfile.Write (Replace(item.body, Chr(13) & Chr(10), Chr(10)))
' Need the extra parameters (especially the binary compare) when using unicode files
tfile.Write (Replace(item.body, Chr(13) & Chr(10), Chr(10), startAt, allOccurrences, vbBinaryCompare))
If Err.Number <> 0 Then
' Clear Err object fields.
' Err.Clear
MsgBox ("OutlookVim: Could not create email file [" & tfolder.ShortPath & "\\" & tname & "] " & vbCrLf & Err.Description)
MsgBox ("OutlookVim: Could not replace newline characters in file [" & tfolder.ShortPath & "\" & tname & "] " & vbCrLf & Err.Number & ":" & Err.Description)
tfile.Close
fso.DeleteFile (tfolder.ShortPath & "\\" & tname)
fso.DeleteFile (tfolder.ShortPath & "\" & tname)
' Quit will close Outlook
' Quit
Exit Sub
Expand All @@ -221,20 +271,20 @@ Sub Edit()
If Err.Number <> 0 Then
' Clear Err object fields.
' Err.Clear
MsgBox ("OutlookVim: Could not create control file [" & tfolder.ShortPath & "\\" & tname & "] " & vbCrLf & Err.Description)
MsgBox ("OutlookVim: Could not create control file [" & tfolder.ShortPath & "\" & tname & "] " & vbCrLf & Err.Description)
cfile.Close
fso.DeleteFile (tfolder.ShortPath & "\\" & tname)
fso.DeleteFile (tfolder.ShortPath & "\\" & tname & ".ctl")
fso.DeleteFile (tfolder.ShortPath & "\" & tname)
fso.DeleteFile (tfolder.ShortPath & "\" & tname & ".ctl")
' Quit will close Outlook
' Quit
Exit Sub
End If
cfile.Close
' MsgBox ("id:" & item.EntryID)
' MsgBox tfolder.ShortPath & "\\" & tname
' MsgBox tfolder.ShortPath & "\" & tname


vimKeys = ":call Outlook_EditFile( '" & tfolder.ShortPath & "\\" & tname & "', '"
vimKeys = ":call Outlook_EditFile( '" & tfolder.ShortPath & "\" & tname & "', '"
If unicode Then
vimKeys = vimKeys & "utf-16"
End If
Expand Down
10 changes: 5 additions & 5 deletions plugin/outlook.vim
@@ -1,11 +1,11 @@
" outlook.vim - Edit emails using Vim from Outlook
" ---------------------------------------------------------------
" Version: 7.0
" Version: 8.0
" Authors: David Fishburn <dfishburn dot vim at gmail dot com>
" Last Modified: 2012 Sep 27
" Last Modified: 2013 Jan 10
" Created: 2009 Jan 17
" Homepage: http://vim.sourceforge.net/script.php?script_id=3087
" Help: :h outlook.txt
" Homepage: http://www.vim.org/scripts/script.php?script_id=3087
" Help: :h outlook.txt
"


Expand Down Expand Up @@ -236,7 +236,7 @@ if has('autocmd') && !exists("g:loaded_outlook")
augroup END

" Don't re-run the script if already sourced
let g:loaded_outlook = 7
let g:loaded_outlook = 8

let @"=saveB
endif
Expand Down
8 changes: 4 additions & 4 deletions plugin/outlookvim.js
@@ -1,9 +1,9 @@
// outlookvim.js
//
// Author: David Fishburn
// Version: 7.0
// Last Modified: 2012 Sep 26
// Homepage: http://vim.sourceforge.net/script.php?script_id=3087
// Version: 8.0
// Last Modified: 2013 Jan 10
// Homepage: http://www.vim.org/scripts/script.php?script_id=3087
//
// Purpose:
// To be used in conjunction with the OutlookVim plugin to allow
Expand All @@ -25,7 +25,7 @@
// http://msdn2.microsoft.com/en-us/library/yek4tbz0.aspx
//
var objArgs = WScript.Arguments;
var version = 7;
var version = 8;

function updateOutlook( emailfile, persistfiles )
{
Expand Down

0 comments on commit c3e4ebc

Please sign in to comment.