Das Notes Forum
Domino 9 und frühere Versionen => Entwicklung => Thema gestartet von: D. Roth. am 27.12.04 - 14:10:20
-
Mail Attachment in eine Neues Dokument kopieren , hat jemand eine Idee ?
Meine erste Idee war das Feld Body mit CopyItem zu koppeiren , aber wenn ich das mache zeigt es mir im neue Feld nichts an . Sonst noch Ideen
-
CopyItem kopiert ein Item in das gleiche Dokument, Du müsstest CopyItemToDocument verwenden.
Ob das allerdings bei Mails der beste Weg ist ? Dabei kopierst Du ja auch den gesamten anderen Inhalt des Body-Feldes mit ...
Bernhard
-
By the way: Ein paar mehr Infos über Deine Rahmenumstände wären auch nicht schlecht. Allein schon, ob Front- oder Backend - das macht eine Menge aus.
Bernhard
-
Dim getmail As GetMail
Dim s As New NotesSession
Dim ws As New NotesUIWorkspace
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim uidoc As Notesuidocument
Set db = s.CurrentDatabase
Dim BodyItem As NotesItem
Set uidoc = ws.currentdocument
Set doc = uidoc.document
Set getmail = New GetMAil
Call getmail.getBodyItem
Call getmail.getSubjectItem
doc.SaveOptions = 0
Call doc.save(True,True)
Call uidoc.close
Set ItemBody = doc.CopyItem( getmail.BodyItem ,"FrmDocContent" )
Set ItemBody = doc.CopyItem( getmail.SubjectItem, "FrmDocTitel" )
' Call getmail.BodyItem.CopyItemToDocument( doc, "FrmDocContent" )
Call doc.ComputeWithForm(False, False)
Call ws.EditDocument( True, doc )
doc.SaveOptions = 1
Call doc.save(True,True)
-
Dim getmail As GetMail Schlecht, ganz schlecht: Objektname = Klassenname !
Dim s As New NotesSession
Dim ws As New NotesUIWorkspace
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim uidoc As Notesuidocument
Set db = s.CurrentDatabase
Dim BodyItem As NotesItem
Set uidoc = ws.currentdocument
Set doc = uidoc.document
Set getmail = New GetMAil
Call getmail.getBodyItem
Call getmail.getSubjectItem
doc.SaveOptions = 0 Wozu ?
Call doc.save(True,True) Wozu ?
Call uidoc.close
Da haben wir es doch: Du kopierst die Items innerhalb des Dokuments doc - siehe mein erstes Posting
Set ItemBody = doc.CopyItem( getmail.BodyItem ,"FrmDocContent" )
Set ItemBody = doc.CopyItem( getmail.SubjectItem, "FrmDocTitel" )
' Call getmail.BodyItem.CopyItemToDocument( doc, "FrmDocContent" )
Call doc.ComputeWithForm(False, False)
Call ws.EditDocument( True, doc )
doc.SaveOptions = 1 Wozu ?
Call doc.save(True,True)
-
Sorry das war der flasche Code wart ich such den richtigen ;-(
-
flasche Code
Kann man wohl sagen ...
-
ü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
-
Hallo Ulrich,
thank you for Invitation !
an den DevTip von searchdomino habe ich gerade auch gedacht, du warst schneller.
Jürgen
-
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
-
"neon" braucht aber lange, den richtigen Code herauszusuchen ...
@Uwe AKA datenbanken24:
Prinzipbedingt wirst Du wohl nicht in de Lage sein, einzelne Attachments ohne den Umweg via Platte zu transferieren. Wobei auch hier das "offene Messer" bleibt, das es Probleme gibt, wenn zwei Attachments mit gleichem Filenamen (was ja ohne weiteres möglich ist) in einem Dokument existieren ... Da ist jetzt wirklich das "Quality"-Team gefragt - und dem sollte Druck gemacht werden.
@neon: Mich interessiert jetzt wirklich, wie das nun weitergeht. Hier haben ja nun einige Zeit investiert ...
Bernhard
@Uwe: Liest Du PMs ?
-
So was lange wärt wird endlich gut. Sorry hatte ;D Urlaub ;D!
Die Post von eknori hört sich gut werd ich gleich probieren!!
der aktuelle Souce Code :
Dim Cgetmail As GetMail
Dim s As New NotesSession
Dim ws As New NotesUIWorkspace
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim uidoc As Notesuidocument
Set db = s.CurrentDatabase
Dim BodyItem As NotesItem
Set uidoc = ws.currentdocument
Set doc = uidoc.document
Set Cgetmail = New GetMAil
Call Cgetmail.getBodyItem
Call Cgetmail.getSubjectItem
' Set ItemBody = doc.CopyItem( Cgetmail.BodyItem ,"FrmDocContent" )
Call Cgetmail.BodyItem.CopyItemToDocument( doc, "FrmDocContent" )
-
So hab den Source Code von eknori ausprobiert aber leider funktioniert er nicht wenn, man Attachments aus Mails kopieren will. Nämlich sobald, man das Body Feld löscht verschwinden auch die $File Felder.
Der Source Code ist noch im Teststadium ;-)
Dim Cgetmail As GetMail
Dim s As New NotesSession
Dim ws As New NotesUIWorkspace
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim uidoc As Notesuidocument
Set db = s.CurrentDatabase
Dim BodyItem As NotesItem
Set uidoc = ws.currentdocument
Set doc = uidoc.document
Set Cgetmail = New GetMAil
Call Cgetmail.getBodyItem
Call Cgetmail.getSubjectItem
Dim DocTemp As NotesDocument
Set ItemBody = doc.CopyItem( Cgetmail.SubjectItem, "FrmDocTitel" )
'Create a temporary document and use CopyAllItems from the current document
'because I know that will include the attachment
Set docTemp = db.CreateDocument
Call Cgetmail.Maildoc.CopyAllItems (docTemp)
Stop
'Clear all items not named $File from the temp docSource, so that allthat's left is the attachment
Forall item In docTemp.Items
If Not (Ucase(item.Name) = "$FILE") Then
If Not (item.Name = "Body" ) Then
docTemp.RemoveItem (item.Name)
End If
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 (doc)
doc.RemoveItem ("Body")
Call doc.save(True,True)