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.
THE SCRIPT FOR LAUNCH PRINT PROCESS
@Command( [FilePrint] ; "" ; ""; ""; ""; ""; ""; "";
"";"";"");@Command([ToolsRunMacro];"(ImprPiecesJointes)")

(Declarations)
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
Randomize
TmpRep= RendTmpRepertoire
If TmpRep = "" Then Msgbox "Error tmp no found" , 16 , "Directory
error"
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)

Next
Close
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)) <> ""
Then
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, ".")))
Wend
If Len(ExtensionFichier) > 3 Then
ExtensionFichier = Left$(Extensi
This was first published in November 2000

Dig deeper on Domino Resources - Part 6

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

-ADS BY GOOGLE

SearchWinIT

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchEnterpriseLinux

SearchVirtualDataCentre.co.UK

Close