Manage Learn to apply best practices and optimize your operations.

Printing All Attachments From A Document

This LotusScript provide you the ability to print all attachments from a
document (or a list of documents). This is only usable for WIN32.
There is noot the ability to print crypt message of document. Improuvements
will be appreciate.
A special thank to Sylvain Coste and Loic Fabro for theiir great help.
@Command( [FilePrint] ; "" ; ""; ""; ""; ""; ""; "";

As StringDim ret As IntegerDim NewDoc As NotesDocumentDim Noms As
VariantDeclare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA"
(Byval hwnd As Long, Byval lpOperation As String, Byval lpFile As String, Byval
lpParameters As String, Byval lpDirectory As String, Byval nShowCmd As Long) As
LongSub Initialize
Dim workspace As New NotesUIWorkspace Dim uidoc As NotesUIDocument
Set uidoc = workspace.CurrentDocument Dim Session As New NotesSession
Dim db As NotesDatabase
Set db = Session.CurrentDatabase Dim doc As NotesDocument
Set doc = session.DocumentContext Dim LogFileNumber As Integer Dim
LogFileName As String
Dim hwnd As Long 'the windows handle don't need to initalize
Dim lpOperation As String
Dim lpFile As String
Dim lpParameters As String
Dim lpDirectory As String
Dim nShowCmd As Long
Dim Hwin32 As Long 'the windows target handle dont need to initalize
Dim Ret As Integer
TmpRep= RendTmpRepertoire
If TmpRep = "" Then Msgbox "Error tmp no found" , 16 , "Directory
Exit Sub
End If
Ret = ModeleDetachePourVueUI( db ) If Ret = False Then
Msgbox "Detach error"
Exit Sub
End If
Dim j As Integer ' open report file
LogFileNumber = Freefile() LogFileName = "prn_rep.txt"
Open TmpRep & "\" & LogFileName For Output As LogFileNumber
Print #LogFileNumber, "Doc Proccess :" Print #LogFileNumber, " "
If Not Isempty(Noms) Then For j = 0 To Ubound(Noms) lpFile
= Noms(j) 'Describe the file name lpDirectory = TmpRep 'Describe
file location
nShowCmd =0 'Show the open file lpOperation = "Print" 'if
you want to open the file change to "Open" ' and finally execute
the action on the file
Hwin32 = ShellExecute(hwnd, lpOperation, lpFile, "", lpDirectory, nShowCmd)

LogFileNumberHwin32 = ShellExecute(hwnd, lpOperation, LogFileName, "",
lpDirectory, nShowCmd)End IfEnd SubFunction RendTmpRepertoireOn Error Goto
err_env RendTmpRepertoire= Environ("TEMP")Exit Functionerr_env:
Msgbox "TEMP doen't exist."
RendTmpRepertoire = ""
Exit Function
End Function
Function ModeleDetachePourVueUI (db As NotesDatabase) As Integer
ModeleDetachePourVueUI = True Dim workspace As New NotesUIWorkspace Dim
view As NotesView
Dim doc As NotesDocument
Dim embobj As NotesDocument
Dim collection As NotesDocumentCollection
Dim rtitem As Variant
Dim NomsDocCourant As Variant Dim NbNoms As Integer
Set collection = db.UnprocessedDocuments
For jj = 1 To collection.Count Set doc = collection.GetNthDocument( jj
If doc Is Nothing Then
ModeleDetachePourVueUI = True
Exit Function
End If

Const Const Noms "@AttachmentNames" NomsDocCourant =
Evaluate(ConstNoms ,doc)
NbNoms = Ubound(NomsDocCourant) If Trim( NomsDocCourant(0)) <> ""
For i = 0 To NbNoms
Set rtitem = doc.GetAttachment( NomsDocCourant(i) )
If rtitem.Type = EMBED_ATTACHMENT Then Print "File detach
"+NomsDocCourant(i) Print tmprep & "\" & NomsDocCourant(i)

NouveauNomFichier = Trim(Left$(NomsDocCourant(i), 4))
If Instr(NouveauNomFichier, ".") > 0 Then NouveauNomFichier =
Trim(Left(NouveauNomFichier, Instr(NouveauNomFichier, ".") - 1))
End If
Aleatoire = Trim(Str( Round(Rnd() * 10000,0)))
NouveauNomFichier = NouveauNomFichier & Aleatoire
ExtensionFichier = Trim(NomsDocCourant(i))
While (Instr(ExtensionFichier, ".") > 0)
ExtensionFichier = Trim(Right$(ExtensionFichier, Len(ExtensionFichier) -
Instr(ExtensionFichier, ".")))
If Len(ExtensionFichier) > 3 Then
ExtensionFichier = Left$(Extensi

Dig Deeper on Domino Resources - Part 6



  • Favorite iSeries cheat sheets

    Here you'll find a collection of valuable cheat sheets gathered from across the iSeries/ community. These cheat ...

  • HTML cheat sheet

    This is a really cool cheat sheet if you're looking to learn more about HTML. You'll find just about everything you every wanted ...

  • Carol Woodbury: Security

    Carol Woodbury