在Notes郵件裡建立按鈕, 自動打開附加檔
Cory Ma 2009 March 23 上午 10:56:36
最近有人請我做一個button在郵件裡面, 讓使用者按下button即可自動打開郵件內的附加檔(有人問, 直接double-click附加檔不就可以打開了...嗯.....應該是直接去double-click附加檔, 跟去按一個button, 對收信者的吸引力不同吧!)
Notes的一大特性, 就是客製化空間很大. 使用者可以自己在自己的郵件裡面, 做個button, 並在button裡面放入程式. 當然Outlook也可以寫VBA執行程式, Outlook使用者可不可以直接放個button在信裡面, 我就不知道了, 可能要有用Outlook的人告知一下
在郵件中, 選建立->焦點資訊->按鈕, 即可在郵件中建立一個按鈕
將要打開的附加檔, 放入郵件中.
若要將附加檔隱藏起來, 也可以用建立小節, 將附加檔放在小節中, 將小節字型大小調至最小, 字型顏色調成白色
在button上面按右鍵, 點選編輯按鈕
選擇用戶端, 及LotusScript (如下圖)
將下面程式複製到按鈕程式中, 並修改程式中FILE_NAME所指向的檔名. 接下來, 就把信寄出去就行了
當然, 不止是可以打開PDF, IT部門也可以把一些欲派送的小程式, 利用這個按鈕, 讓使用者按下按鈕, 及執行某特定程式
Sub Click(Source As Button)
Dim doc As NotesDocument
Dim uidoc As NotesUIDocument
Dim w As New NotesUIWorkspace
Dim rtitem As Variant
' Launches imagefile referenced in document, using MS-DOS _START_ command.
Set wsh = CreateObject("WScript.Shell")
' 取得Windows暫存目錄
TempPath = wsh.ExpandEnvironmentStrings("%temp%")
' 要打開或要執行的檔名
Const FILE_NAME = "abc.pdf"
' set START command depending on OS version
Set uidoc = w.CurrentDocument
Set doc = uidoc.Document
Set rtitem = doc.GetFirstItem( "Body" )
If ( rtitem.Type = RICHTEXT ) Then
Forall o In rtitem.EmbeddedObjects
If ( o.Type = EMBED_ATTACHMENT ) Then
If o.source=FILE_NAME Then
Call o.ExtractFile( TempPath & "\" & o.Source )
End If
End If
End Forall
End If
cmd = "start"
platform = Evaluate( "@platform([specific])" )
If platform(0) = "Windows/NT" Then cmd = "cmd /c " + cmd + " " + Chr$(34) + Chr$(34)
cmd = cmd + " "
' 若要在執行檔後面加參數, 請修改下面這行程式
filePath = Chr$(34) +TempPath & "\" & FILE_NAME + Chr$(34)
' Print "Opening " & FILE_NAME
x = Shell( cmd + filePath, 2 )
End Sub
- Comments [5]