Lotusscript opens an attachment with associated application

Const MAX_FILENAME_LEN = 256
Const SHELL_NORMAL_FOCUS = 3
Declare Function FindExecutable Lib "shell32.dll" Alias "FindExecutableA" (Byval lpFile As String,_
Byval lpDirectory As String, Byval lpResult As String) As Long 

 

 Dim ui As New NotesUIWorkspace
 Dim db As NotesDatabase
 Dim collection As NotesDocumentCollection
 Dim doc As NotesDocument
 Dim rtfitme As Variant
 Dim docHandle As Variant

 

 Dim specObj As NotesEmbeddedObject
 Dim tempDir As String
 Dim tempFileName As String
 Dim filePath As String
 Dim exePath As String
 Dim shellPath As String
 Dim exeRes As Long 
 
 Set db = ui.CurrentDatabase.Database
 Set collection = db.Search(|form="XXXX"|,Nothing,0)
 Set doc = collection.GetFirstDocument
 If doc Is Nothing Then
  Msgbox "XXXX XXXX"
 Else
  Set rtfitem = doc.GetFirstItem("XXXX")
  If rtfitem.Type = RICHTEXT Then
   If Isempty(rtfitem.EmbeddedObjects) Then
    Msgbox "XXXX XXXX"
   Else    
    Set specObj = rtfitem.EmbeddedObjects(0)
    tempDir$ = Environ("Temp")
    tempFileName$ = specObj.Source
    filePath$ = tempDir$ & "/" & tempFileName$
    'save the attachment to the temp folder
    Call specObj.ExtractFile(filePath$)
    'create a buffer
    exePath$ = Space$(MAX_FILENAME_LEN) 
    'find the executable
    exeRes& = FindExecutable(filePath$,"",exePath$)
    If exeRes& > 32 Then
     exePath = Left$(exePath, Instr(exePath, Chr$(0)) - 1)
     'open the file
     exeRes = Shell(exePath$ & | "| & filePath$ & |"|,SHELL_NORMAL_FOCUS)
    Else
     Msgbox "No association found !"
    End If  
   End If
  Else
   Msgbox "XXXX XXXX"
  End If
 End If

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值