Domino 9 und frühere Versionen > Entwicklung

Mail Attachment in eine Neues Dokument kopieren

<< < (2/3) > >>

D. Roth.:
Sorry das war der flasche Code wart ich such den richtigen ;-(

koehlerbv:

--- Zitat von: neon am 27.12.04 - 15:19:51 ---flasche Code

--- Ende Zitat ---

Kann man wohl sagen ...

eknori:
über der NeuigkeitenBrief von searchdomino.com kam gerade folgendes herein; möglicherweise hilft das weiter

 
LOTUSSCRIPT
Copy attachments in LotusScript without detaching
Brad Balassaitis
27 Dec 2004
Rating: --- (out of 5)

Please let others know how useful it is via the rating scale at the end of the tip. Do you have a useful Notes/Domino tip or code to share? Submit it to our monthly tip contest and you could win a prize and a spot in our Hall of Fame.


--------------------------------------------------------------------------------

This procedure copies file attachments from the current Web document to an existing document (but it can be modified to work for the Notes client as well just by changing the docSource object).

There is no direct way to copy file attachments -- copying the $FILE item with CopyItemToDocument and using doc.ReplaceItemValue do not work on $FILE items. Using doc.CopyAllItems works, but that is not desirable, as I only want to copy the attachments.

The normal workaround is to detach attachments from the source document to the hard drive and re-attach them to a rich text field on the target document. However, that's often restricted on a server, so I'd like to avoid it.

Here is a better strategy:

Call the function below, passing in the database handle along with the source document and target document objects.

Create new docTemp as blank document.

Copy all items from docSource to docTemp.

Loop through docTemp and delete all items not named $File. Now you have a docSource that only has the attachment(s) on it!

RemoveItem($File) from docTarget (to clear existing attachments).

Call docTemp CopyAllItems to docTarget (this should only copy the attachment).

Save docTarget.

  Code: Sub CopyAttachments (db As NotesDatabase, docSource As
NotesDocument, docTarget As NotesDocument)
 Dim docTemp As NotesDocument
 
 'Remove all attachments from existing document
 Call docTarget.RemoveItem ("$FILE")
 
 'Create a temporary document and use CopyAllItems from the current
document
 'because I know that will include the attachment
 Set docTemp = db.CreateDocument
 Call docSource.CopyAllItems (docTemp)
 
 'Clear all items not named $File from the temp docSource, so that all
that's left is the attachment
 Forall item In docTemp.Items
  If Not (Ucase(item.Name) = "$FILE") Then
   docTemp.RemoveItem (item.Name)
  End If 
 End Forall
 
 'Now, docTemp only has the attachments left on it
 'CopyAllItems will copy the attachment, so use it to copy to docTarget
 Call docTemp.CopyAllItems (docTarget)
 Call docTarget.Save (True, False)
End Sub

 
 

audiojosi:
Hallo Ulrich,

thank you for Invitation !

an den DevTip von searchdomino habe ich gerade auch gedacht, du warst schneller.

Jürgen

datenbanken24:
Diese nette Neuigkeit hatten wir vor ein paar Wochen schon hier im Forum diskutiert.

Die Frage, wie man nun auch einzelne, ganz bestimmte Attachments - und nicht immer alle - auf die Wiese kopiert, wäre interessant...

http://www.atnotes.de/index.php?topic=17896.msg108370#msg108370

Navigation

[0] Themen-Index

[#] Nächste Seite

[*] Vorherige Sete

Zur normalen Ansicht wechseln