1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
| Sub Initialize
Dim doc As NotesDocument
Dim rtitem As NotesRichTextItem
Dim object As NotesEmbeddedObject
Dim object2 As NotesEmbeddedObject
Dim session As New NotesSession
Dim mainpath As String
Dim FirstFileName As String
Dim ev, PathToFile
Set doc=session.DocumentContext
mainpath="\\serveur\Public\Info" 'drive folder used for saving the files
ev=Evaluate("@AttachmentNames",doc)
FirstFileName=ev(0) 'ev(1) to get second file, ev(2) to get third file
If Dir(mainpath,16)="" Then MkDir mainpath
PathToFile=mainpath+"\"+FirstFileName
Set rtitem = doc.GetFirstItem( "transaction.xls" )
If rtitem Is Nothing Then
Set rtitem = New NotesRichTextItem( doc, "Body" )
End If
If ( rtitem.Type = RICHTEXT ) Then
Set object = rtitem.GetEmbeddedObject( FirstFileName )
End If
If ( object Is Nothing ) Then
Set object = doc.GetAttachment( FirstFileName )
End If
If object Is Nothing Then
Exit Sub 'no attachment with that name
End If
Call object.ExtractFile(PathToFile )
Call object.Remove 'remove to avoid multiple attachments with same name
Call doc.Save( True, False)
Set object2 = rtitem.EmbedObject ( EMBED_ATTACHMENT, "", PathToFile)
'Kill (PathToFile) 'remove the file from disk
Call doc.Save( True, False )
End Sub |
Partager