Skip to content
Browse files

Version 1.0: Initial upload

  • Loading branch information...
0 parents commit 39ca4a41936ee8353bfa2f149345fa864e8778a8 @dfishburn dfishburn committed with
Showing with 730 additions and 0 deletions.
  1. +24 −0 README
  2. +196 −0 doc/outlook.txt
  3. +199 −0 plugin/OutlookVim.bas
  4. +167 −0 plugin/outlook.vim
  5. +144 −0 plugin/outlookvim.js
24 README
@@ -0,0 +1,24 @@
+This is a mirror of http://www.vim.org/scripts/script.php?script_id=3087
+
+For Windows users, this plugin will allow you to add a button in Microsoft Outlook which will create a new buffer in Vim with the body of the current email. The buffer can be edited in a specific instance of Vim and you can choose whether to use tabs.
+
+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).
+
+There are a number of preferences you can set within the plugin to customize it for your use.
+These settings can be explored here:
+:h outlook-configuration
+:h outlook.txt
+
+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.
+
+Please use the VimWiki (link at top of page) to post comments and suggestions.
+I routinely monitor the vim_use group.
+
+
+
196 doc/outlook.txt
@@ -0,0 +1,196 @@
+*outlook.txt* For Vim version 7.0. Last change: 2009 Apr 22
+
+
+ VIM REFERENCE MANUAL
+ by
+ David Fishburn <dfishburn dot vim at gmail dot com>
+
+ Outlook Vim Plugin
+ outlook.vim version 1
+
+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=???
+
+*outlook*
+
+1. Overview |outlook-overview|
+2. Whats New |outlook-new|
+3. Installing the plugin |outlook-install|
+4. Installing the Outlook macro |outlook-macro|
+5. Configuration |outlook-configuration|
+
+{Vi does not have any of this}
+
+==============================================================================
+1. Overview *outlook-overview*
+
+This plugin has two parts.
+
+Outlook
+-------
+Outlook allows macros to be created in Visual Basic. This feature is built
+in. Once the macro is imported / created, you can drag and drop the macro
+on to the Outlook standard toolbar. The macro (when executed) does two
+things:
+ 1. Writes the email body out to a file ending in .outlook
+ 2. Writes out a control file ending in .outlook.ctl
+
+Vim
+---
+The outlook.vim plugin is responsible for setting up some autocmds inside
+of Vim. These autocmds are responsible for updating Outlook when the
+buffer (email) is updated.
+
+The autocmds will execute the outlookvim.js (javascript) file which uses
+the .outlook.ctl file to figure out which email to update and puts the
+contents of the .outlook file into the body of the message in Outlook.
+It then deletes these temporary files when finished.
+
+The autocmds also will delete these temporary files if you choose to abandon
+the changes (in Vim) by using :bdelete or closing Vim.
+
+
+After creating the Outlook macro and installing the Vim Outlook plugin, no
+other changes are required except editing and saving your emails.
+
+There are a number of configuration options available see
+|outlook-configuration|
+
+If you have questions or suggestions you can post questions to the Vim mailing
+list. I routinely monitor the list. Comments, feedback and suggestions are
+always welcome.
+
+David Fishburn
+
+
+==============================================================================
+2. What's New *outlook-new*
+
+Version 1
+
+ New Features
+ ------------
+ - Initial release.
+
+
+==============================================================================
+3. Installing the plugin *outlook-install*
+
+ You can use this script as a plugin by copying it to your plugin directory.
+ See |add-global-plugin| for instructions.
+
+ You can also |:source| it from your |.vimrc|.
+
+ To install this help file |add-local-help| inside Vim.
+ :help add-local-help
+ :helptags $VIM/vimfiles/doc (Windows)
+ :helptags $VIM/.vim/doc (Unix)
+
+ NOTE:
+ Vim must be in nocompatible mode for the plugin to operate correctly.
+ This implies you have this line in your |.vimrc|: >
+ set nocompatible
+<
+
+
+==============================================================================
+4. Installing the Outlook macro *outlook-macro*
+
+ The macro is used to add a button in Outlook to lauch Vim. It is used to
+ create the files which Vim will edit. It will also add a shortcut key
+ (Alt-d) to fire up Vim instead of having to use a mouse.
+
+ To install the Outlook macro flip over to Outlook.
+
+ 1. From the Outlook menu Tools->Macro->Security
+ - Make sure this is set to Medium, or the macro will not be enabled
+ 2. From the menu Tools->Macro->Visual Basic Editor (or Alt-F11)
+ 3. From the menu File->Import File (or Ctrl-M)
+ 4. Choose the file C:\Vim\vimfiles\plugin\OutlookVim.bas
+ 5. Expand the Modules folder in the Project pane
+ 6. Right click on OutlookVim and choose Project Properties
+ 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)
+ 10. Close the Visual Basic Editor
+ 11. Double click on an email
+ 12. Right click on the toolbar (of the email message) and choose "Customize"
+ 13. Choose the Commands tab
+ 14. Click on the Macros category
+ 15. Drag and drop the Vim.Edit macro onto the end of the Standard
+ toolbar displayed in the currently open email
+ 16. Click on the Rearrange Commands button
+ 17. Change the radio button to Toolbar: Standard
+ 18. Scroll to the bottom where the Vim.Edit button is and highlight it
+ 19. Click on the Modify Selection button
+ 20. On the dropdown which appears, click on Name
+ 21. Change the name from "Vim.Edit" to "Vim.E&dit"
+ - Now you can press Alt-d as a shortcut to launch Vim to edit
+ the email without having to use the mouse to click on the
+ button (after all, this is the Vim way)
+ 22. Hit Enter, Close and Close to return back to the open email
+ 23. Click on the Vim.Edit button, or hit Ctrl-d to edit the email using Vim
+ 24. Make a minor change to the email (in Vim) and :w
+ 25. Verify the Outlook email has the same change
+ 26. Hit Escape to close the Outlook email, you will be prompted to Save
+ the changes you have just made. So you always have an option of
+ cancelling the changes you made in Vim, in Outlook.
+
+
+ If you changed the Macro Security settings you must restart Outlook
+ for these changes to be active.
+
+
+==============================================================================
+5. Configuration *outlook-configuration*
+
+ The behavior of outlook.vim is governed by several variables. These variables
+ are used by the autocmds which are created by the plugin. These variables can
+ be assigned global defaults which can be set in your |.vimrc|.
+
+ You can override many of the features of this script by creating various
+ variables within your vimrc.
+
+ The outlookvim.js (javascript) file tells Outlook to re-read the message from
+ the temporary file. This allows you to rename it, or place it in any
+ location you want. Here are some examples: >
+ let g:outlook_javascript = '$VIM\vimfiles\plugin\outlookvim.js' (default)
+ let g:outlook_javascript = 'C:\Documents and Settings\Username\My Documents\outlookvim.js'
+ let g:outlook_javascript = expand('$APPDATA\Microsoft\outlookvim.js')
+ let g:outlook_javascript = expand('$USERPROFILE\Application Data\Microsoft\outlookvim.js')
+<
+ This setting overrides the default textwidth the mail ftplugin sets. This
+ allows you to automatically format text using gq by setting the following: >
+ let g:outlook_textwidth = 76
+<
+ When you save a file, by default, Outlook will be updated and the temporary
+ file you are editing will be deleted. Autoread was added so that the Vim
+ buffer is automatically cleared instead of displaying a warning message
+ indicating the file has changed outside of Vim (in fact it was deleted). If
+ you wish to see the warning, you can set the following: >
+ let g:outlook_noautoread = 1
+<
+ When you save a file, by default, Outlook will be updated and the temporary
+ file you are editing will be deleted. Since the file has been deleted, you
+ are left editing a file that no longer exists. By default, the Vim buffer
+ will be deleted automatically, unless this option is set. >
+ let g:outlook_nobdelete = 1
+<
+ If you do not save the temporary file and instead decide to throw away your
+ changes, the temporary files will be cleaned up. This option will leave the
+ files in the temporary directory instead of removing them. >
+ let g:outlook_nodelete_unload = 1
+<
+ This setting will prevent the script from automatically turning on Vim's
+ autoindent feature. It will use your default setting instead. >
+ let g:outlook_noautoindent = 1
+<
+ This setting will turn on additional debugging output to help identify where
+ any problems may lie. >
+ let g:outlook_save_cscript_output = 1
+<
+
+ vim:tw=78:fo=tcq2:ts=8:ft=help:norl:
199 plugin/OutlookVim.bas
@@ -0,0 +1,199 @@
+Attribute VB_Name = "OutlookVim"
+' This code came from here originally:
+' http://barnson.org/node/295
+' Some links might be useful
+' http://office.microsoft.com/en-us/help/HA010429591033.aspx
+' Macro Security settings and creating digit certificates
+' http://www.pcreview.co.uk/forums/thread-854025.php
+
+Option Explicit
+
+Private Type STARTUPINFO
+ cb As Long
+ lpReserved As String
+ lpDesktop As String
+ lpTitle As String
+ dwX As Long
+ dwY As Long
+ dwXSize As Long
+ dwYSize As Long
+ dwXCountChars As Long
+ dwYCountChars As Long
+ dwFillAttribute As Long
+ dwFlags As Long
+ wShowWindow As Integer
+ cbReserved2 As Integer
+ lpReserved2 As Long
+ hStdInput As Long
+ hStdOutput As Long
+ hStdError As Long
+End Type
+
+Private Type PROCESS_INFORMATION
+ hProcess As Long
+ hThread As Long
+ dwProcessID As Long
+ dwThreadID As Long
+End Type
+
+Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal _
+ hHandle As Long, ByVal dwMilliseconds As Long) As Long
+
+Private Declare Function CreateProcessA Lib "kernel32" (ByVal _
+ lpApplicationName As Long, ByVal lpCommandLine As String, ByVal _
+ lpProcessAttributes As Long, ByVal lpThreadAttributes As Long, _
+ ByVal bInheritHandles As Long, ByVal dwCreationFlags As Long, _
+ ByVal lpEnvironment As Long, ByVal lpCurrentDirectory As Long, _
+ lpStartupInfo As STARTUPINFO, lpProcessInformation As _
+ PROCESS_INFORMATION) As Long
+
+Private Declare Function CloseHandle Lib "kernel32" (ByVal _
+ hObject As Long) As Long
+
+Private Const NORMAL_PRIORITY_CLASS = &H20&
+Private Const INFINITE = -1&
+
+Sub Edit()
+ On Error Resume Next
+
+ 'Dim windir As String
+
+ 'windir = Environ("WinDir")
+
+ 'Shell (windir & "\system32\cscript.exe " & windir & "\system32\launchvim.vbs")
+
+ Const TemporaryFolder = 2
+ ' Const VIMLocation = "C:\Vim\vim72\gvim.exe"
+
+
+ Dim ol, insp, item, body, fso, tempfile, tfolder, tname, tfile, cfile, appRef, x, Vim, vimKeys
+ Dim overwrite As Boolean, unicode As Boolean
+
+ ' MsgBox ("Just starting LaunchVim")
+
+ Set ol = Application
+
+ Set insp = ol.ActiveInspector
+ If insp Is Nothing Then
+ ' MsgBox ("No active inspector")
+ Exit Sub
+ End If
+
+ Set item = insp.CurrentItem
+ If item Is Nothing Then
+ ' MsgBox ("No current item")
+ Exit Sub
+ End If
+
+
+ body = CStr(item.body)
+
+ Set fso = CreateObject("Scripting.FileSystemObject")
+ Set tfolder = fso.GetSpecialFolder(TemporaryFolder)
+ tname = fso.GetTempName
+ tname = Left(tname, (Len(tname) - 3)) & "outlook"
+ ' MsgBox ("Temp folder:" & tfolder.ShortPath)
+
+ ' Write out the body of the message to a temp file
+ overwrite = False
+ unicode = False
+ ' MsgBox ("InternetCodePage:" & item.InternetCodepage)
+
+ ' Check if there are any unicode characters in the body
+ If InStr(1, item.body, Chr(0), vbBinaryCompare) > 0 Then
+ ' MsgBox ("Setting unicode")
+ unicode = True
+ End If
+
+ Set tfile = tfolder.CreateTextFile(tname, overwrite, unicode)
+ ' MsgBox ("Created body file:" & tfile.Name)
+
+ ' tfile.Write (Replace(body, Chr(13) & Chr(10), Chr(10)))
+ tfile.Write (item.body)
+ If Err.Number <> 0 Then
+ ' Clear Err object fields.
+ ' Err.Clear
+ MsgBox ("Could not convert CRLFs:" & vbCrLf & Err.Description)
+ tfile.Close
+ fso.DeleteFile (tfolder.ShortPath & "\" & tname & "\" & tname)
+ ' Quit will close Outlook
+ ' Quit
+ Exit Sub
+ End If
+ 'Try
+ ' tfile.Write (Replace(body, Chr(13) & Chr(10), Chr(10)))
+ ' Catch ex As Exception
+ 'Catch
+ ' tfile.Write (body)
+ ' MsgBox ("Could not convert CRLFs:" & vbCrLf & ex.Message)
+ 'End Try
+
+ tfile.Close
+ ' MsgBox ("tfile:" & tname)
+
+ ' Write out the control file so the outlookvim javascript file
+ ' can tell Outlook which file to refresh from
+ Set cfile = tfolder.CreateTextFile(tname & ".ctl")
+ cfile.Write (Replace(item.EntryID, Chr(13) & Chr(10), Chr(10)))
+ cfile.Close
+ ' MsgBox ("id:" & item.EntryID)
+ ' MsgBox tfolder.ShortPath & "\" & tname
+
+ ' Create an instance of Vim (if one does not already exist)
+ Set Vim = CreateObject("Vim.Application")
+ If Vim Is Nothing Then
+ MsgBox ("Could not create a Vim OLE object, please ensure Vim has been installed." & vbCrLf & "Inside Vim, run this command, it should echo 1," & vbCrLf & " :echo has('ole')")
+ Exit Sub
+ End If
+
+ vimKeys = "<ESC>:e "
+ If unicode Then
+ vimKeys = vimKeys & " ++enc=utf-16 "
+ End If
+ vimKeys = vimKeys & tfolder.ShortPath & "\" & tname & "<Enter>"
+
+ ' MsgBox (vimKeys)
+ ' Use Vim's OLE feature to edit the email
+ ' This allows us to re-use the same Vim for multiple emails
+ Vim.SendKeys vimKeys
+
+ ' Force the Vim to the foreground
+ Vim.SetForeground
+
+ ' Do not spawn a new instance of Vim
+ ' ExecCmd VIMLocation & " " & Chr(34) & tfolder.Path & "\" & tname & Chr(34)
+
+ ' Since the above Vim command forks, do not bother to wait
+ ' and read and delete the file
+ ' Set tfile = fso.OpenTextFile(tfolder.Path & "\" & tname, 1)
+ ' item.body = Replace(tfile.ReadAll, Chr(10), Chr(13) & Chr(10))
+ ' tfile.Close
+
+ ' Outlookvim javascript file will delete the file when finished
+ ' fso.DeleteFile (tfolder.Path & "\" & tname)
+
+Finished:
+End Sub
+
+Public Sub ExecCmd(cmdline$)
+
+ Dim proc As PROCESS_INFORMATION
+ Dim start As STARTUPINFO
+ Dim ReturnValue As Integer
+
+ ' Initialize the STARTUPINFO structure:
+ start.cb = Len(start)
+
+ ' Start the shelled application:
+ ReturnValue = CreateProcessA(0&, cmdline$, 0&, 0&, 1&, _
+ NORMAL_PRIORITY_CLASS, 0&, 0&, start, proc)
+
+ ' Wait for the shelled application to finish:
+ Do
+ ReturnValue = WaitForSingleObject(proc.hProcess, 0)
+ DoEvents
+ Loop Until ReturnValue <> 258
+
+ ReturnValue = CloseHandle(proc.hProcess)
+
+End Sub
167 plugin/outlook.vim
@@ -0,0 +1,167 @@
+" outlook.vim - Edit emails using Vim from Outlook
+" ---------------------------------------------------------------
+" Version: 1
+" Authors: David Fishburn <dfishburn dot vim at gmail dot com>
+" Last Modified: 2009 Apr 21
+" Created: 2009 Jan 17
+" Homepage: http://vim.sourceforge.net/script.php?script_id=???
+" Help: :h outlook.txt
+"
+
+
+" Only use this on the Windows platforms
+if !has("win32") && !has("win95") && !has("win64")
+ finish
+endif
+
+if exists('g:loaded_outlook') || &cp
+ finish
+endif
+
+" View the output (by default) if an update fails
+let g:outlook_save_cscript_output = 1
+
+" Default location for the outlookvim.js file.
+" This can be overridden in your vimrc via
+" g:outlook_javascript
+let s:outlook_javascript_default = expand('$VIM/vimfiles/plugin/outlookvim.js')
+
+" autoindent - preserve indent level on new line
+if !exists('g:outlook_noautoindent')
+ setlocal autoindent
+endif
+
+" textwidth - automatically wrap at a column
+if exists('g:outlook_textwidth')
+ let &textwidth = g:outlook_textwidth
+else
+ let &textwidth = 76
+endif
+
+function! Outlook_WarningMsg(msg)
+ echohl WarningMsg
+ echomsg a:msg
+ echohl None
+endfunction
+
+function! Outlook_ErrorMsg(msg)
+ echohl ErrorMsg
+ echomsg a:msg
+ echohl None
+endfunction
+
+function! Outlook_ExecuteJS(filename)
+ let cmd = "echo system('cscript \""
+ if exists('g:outlook_javascript')
+ let cmd = cmd . expand(g:outlook_javascript)
+ else
+ let cmd = cmd . s:outlook_javascript_default
+ endif
+ let cmd = cmd . '" "'.a:filename.'"'
+ let cmd = cmd . " ')"
+ exec cmd
+endfunction
+
+" Check is cscript.exe is already in the PATH
+" Some path entries may end in a \ (c:\util\;), this must also be replaced
+" or globpath fails to parse the directories
+if strlen(globpath(substitute($PATH, '\\\?;', ',', 'g'), 'cscript.exe')) == 0
+ call Outlook_ErrorMsg("outlook: Cannot find cscript.exe in system path")
+ finish
+endif
+
+if exists('g:outlook_javascript')
+ if !filereadable(expand(g:outlook_javascript))
+ call Outlook_ErrorMsg("outlook: Cannot find javascript: " .
+ \ expand(g:outlook_javascript) )
+ finish
+ endif
+else
+ if !filereadable(expand(s:outlook_javascript_default))
+ call Outlook_ErrorMsg("outlook: Cannot find javascript: " .
+ \ expand(s:outlook_javascript_default) )
+ finish
+ endif
+endif
+
+" These autocommands only need to be created once,
+" so store a script variable to prevent reloading
+if has('autocmd') && !exists("g:loaded_outlook")
+ " Save the current default register
+ let saveB = @"
+
+ " Check to see if the BufWritePost autocommand already exists
+ redir @"
+ silent! exec 'augroup'
+ redir END
+
+ if @" !~? '\<outlook\>'
+
+ " Create a group of the autocommands for outlook
+ augroup outlook
+ " Remove the previous group (if it existed)
+ au!
+
+ " Each time we enter this buffer, set the filetype to mail
+ " which allows us to rely on each personal users mail preferences
+ let cmd = 'autocmd BufEnter *.outlook setlocal filetype=mail '
+ exec cmd
+
+ " nested is required since we are issuing a bdelete, inside an autocmd
+ " so we also need the required autocmd to fire for that command.
+ " setlocal autoread, prevents this message:
+ " "File has changed, do you want to Load"
+
+ let cmd = 'autocmd BufWritePost *.outlook nested '
+ if !exists('g:outlook_noautoread')
+ let cmd = cmd . 'setlocal autoread | '
+ endif
+
+ " silent! !start is to prevent the "Press any key to continue message"
+ " This is behaviour I (dfishburn) prefer, when we write the file, the
+ " buffer is deleted, and removed from the list of files in the Vim
+ " session. outlookvim.js has already deleted the temporary file from the
+ " filesystem.
+ let cmd = cmd . "let g:outlook_cscript_output = system('cscript \""
+ if exists('g:outlook_javascript')
+ let cmd = cmd . expand(g:outlook_javascript)
+ else
+ let cmd = cmd . s:outlook_javascript_default
+ endif
+ let cmd = cmd . '" "'."'".'.expand("%").'."'".'"'
+ let cmd = cmd . " ')"
+
+ if !exists('g:outlook_nobdelete')
+ let cmd = cmd . "| bdelete "
+ endif
+ if g:outlook_save_cscript_output == 1
+ let cmd = cmd . "| if g:outlook_cscript_output =~ 'outlook:' | echo g:outlook_cscript_output | endif "
+ endif
+
+ exec cmd
+
+ " This is necessary in case the buffer is not saved (:w), since
+ " the temporary files are only deleted by outlookvim.js.
+ " But the javascript is only called if you save the buffer, if
+ " you choose to abandon your edits, the temporary files are left
+ " over in the temporary directory.
+ if !exists('g:outlook_nodelete_unload')
+ let cmd = "autocmd BufUnload *.outlook " .
+ \ "if expand('%:e') == 'outlook' " .
+ \ "| call delete(expand('%:p').'.ctl') " .
+ \ "| call delete(expand('%:p')) " .
+ \ "| endif"
+ exec cmd
+ endif
+
+ augroup END
+
+ endif
+
+ " Don't re-run the script if already sourced
+ let g:loaded_outlook = 1
+
+ let @"=saveB
+endif
+
+" vim:fdm=marker:nowrap:ts=4:expandtab:
144 plugin/outlookvim.js
@@ -0,0 +1,144 @@
+// Overview of Windows Scripting
+// http://msdn2.microsoft.com/en-us/library/ms950396.aspx
+//
+// Microsoft JScript Documentation
+// http://msdn2.microsoft.com/en-us/library/hbxc2t98.aspx
+//
+// JScript Language Reference
+// http://msdn2.microsoft.com/en-us/library/yek4tbz0.aspx
+//
+var objArgs = WScript.Arguments;
+var emailfile = objArgs(0);
+
+function updateOutlook( emailfile )
+{
+ var ctlfile = emailfile + ".ctl";
+ var outlook = null;
+ var fs = null;
+ var f = null;
+ var fid = null;
+ var objNS = null;
+ var objInbox = null;
+ var entryID = null;
+ var newmsg = null;
+ var inspector = null;
+
+ try
+ {
+ outlook = new ActiveXObject("Outlook.Application");
+ }
+ catch(err)
+ {
+ WScript.Echo("outlookvim: Unable to create Outlook.Application:"+err.message);
+ return;
+ }
+ try
+ {
+ fs = new ActiveXObject("Scripting.FileSystemObject");
+ }
+ catch(err)
+ {
+ WScript.Echo("outlookvim: Unable to create Scripting.FileSystemObject:"+err.message);
+ return;
+ }
+ try
+ {
+ f = fs.OpenTextFile(emailfile);
+ }
+ catch(err)
+ {
+ WScript.Echo("outlookvim: Unable to open file:"+emailfile+" err:"+err.message);
+ return;
+ }
+ try
+ {
+ fid = fs.OpenTextFile(ctlfile);
+ }
+ catch(err)
+ {
+ WScript.Echo("outlookvim: Unable to open control file:"+ctlfile+" err:"+err.message);
+ return;
+ }
+ try
+ {
+ objNS = outlook.GetNamespace("MAPI");
+ }
+ catch(err)
+ {
+ WScript.Echo("outlookvim: Unable to get outlook namespace:"+err.message);
+ return;
+ }
+ try
+ {
+ objInbox = objNS.GetDefaultFolder(6);
+ }
+ catch(err)
+ {
+ WScript.Echo("outlookvim: Unable to get Inbox:"+err.message);
+ return;
+ }
+ try
+ {
+ entryID = fid.ReadLine();
+ }
+ catch(err)
+ {
+ WScript.Echo("outlookvim: Failed to read control file["+ctlfile+"]:"+err.message);
+ return;
+ }
+ try
+ {
+ newmsg = objNS.GetItemFromID(entryID);
+ }
+ catch(err)
+ {
+ WScript.Echo("outlookvim: GetItemFromID failed:"+err.message);
+ return;
+ }
+ try
+ {
+ newmsg.Body = f.ReadAll();
+ }
+ catch(err)
+ {
+ WScript.Echo("outlookvim: Failed to read email file["+emailfile+"]:"+err.message);
+ return;
+ }
+
+ fid.Close();
+ f.Close();
+ try
+ {
+ inspector = newmsg.GetInspector;
+ inspector.Activate();
+ }
+ catch(err)
+ {
+ WScript.Echo("outlookvim: Failed to get Inspector:"+err.message);
+ return;
+ }
+
+ try
+ {
+ f = fs.GetFile(emailfile);
+ f.Delete();
+ }
+ catch(err)
+ {
+ WScript.Echo("outlookvim: Failed to get and delete email file["+emailfile+"]:"+err.message);
+ }
+ try
+ {
+ fid = fs.GetFile(ctlfile);
+ fid.Delete();
+ }
+ catch(err)
+ {
+ WScript.Echo("outlookvim: Failed to get and delete control file["+ctlfile+"]:"+err.message);
+ }
+ WScript.Echo("Successfully updated Outlook, message ID:"+entryID);
+}
+
+updateOutlook( emailfile );
+
+

0 comments on commit 39ca4a4

Please sign in to comment.
Something went wrong with that request. Please try again.