Das Notes Forum
Domino 9 und frühere Versionen => ND6: Entwicklung => Thema gestartet von: waldt am 18.03.08 - 08:16:54
-
Hallo zusammen,
ich habe hier ein Script von eknori gefunden, welches das macht was ich benötige.
Benutzer sollen auf eine Mail antworten und dabei eine Vorlage auswählen.
Das klappt auch soweit gut.
Allerdings übernimmt die Funktion keine Anhänge der in der Vorlage drin sind.
Kann mir da jemand helfen?
Hier das Script:
Sub Click(Source As Button)
Dim ws As New NotesUIWorkspace
Dim session As New NotesSession
Dim db As NotesDatabase
Dim collection As notesdocumentcollection
Dim replyToUIDoc As NotesUIDocument
Dim stationeryDoc As NotesDocument
Set db = session.CurrentDatabase
Set replyToUIDoc = ws.ComposeDocument("","","Reply")
Set collection = ws.Picklistcollection(PICKLIST_CUSTOM, False, db.server, db.filepath, "Stationery", "Select Stationery", "Please select stationery for new memo.")
Set stationeryDoc = collection.getfirstdocument
If Not stationeryDoc Is Nothing Then
Dim stationeryBodyItem
Set stationeryBodyItem = stationeryDoc.getfirstitem("Body")
Call replyToUIDoc.GotoField( "Body" )
Call replyToUIDoc.SelectAll
Call replyToUIDoc.Cut
Call replyToUIDoc.InsertText( stationeryBodyItem.GetFormattedText( False, 0 ) )
Else
Call replyToUIDoc.Close
End If
End Sub
Vielen Dank im voraus,
Gruß
Thomas
-
Das kann auch so nicht funktionieren. Du markierst zwar den gesamten Inhalt des Body-Feldes, fügst aber dann nur Text in das andere Feld ein.
Schau dir mal die Methode CopyItem aus der Klasse NotesDocument in der Designer-Hilfe an. Dort ist auch ein Beispiel vorhanden, dass sich ein Stück weit sich auf deine Problematik bezieht.
Axel
-
Hallo Axel,
danke für die schnelle Antwort.
Ich bin leider nicht so fit in der Entwicklung.
Ich bin Administrator, werde aber versuchen was rauszufinden.
Nur so lernt man was :-)
Danke für die schnelle Info.
Wenn ich probleme bekomme, melde ich mich noch mal.
Gruß
Thomas
-
Hier mal auf die Schnelle eine ungetesteter Lösungsvorschlag aus dem Kopf.
Dim replyToUIDoc As NotesUIDocument
Dim replyToDoc As NotesDocument
Dim stationeryDoc As NotesDocument
Dim stationeryBodyItem As NotesRichTextItem
Set db = session.CurrentDatabase
Set collection = ws.Picklistcollection(PICKLIST_CUSTOM, False, db.server, db.filepath, "Stationery", "Select Stationery", "Please select stationery for new memo.")
Set stationeryDoc = collection.getfirstdocument
If Not stationeryDoc Is Nothing Then
Set replyToDoc = New NotesDocument(db)
replyToDoc.Form="Reply"
Set stationeryBodyItem = stationeryDoc.getfirstitem("Body")
Call replyToDoc.CopyItem( stationeryBodyItem, "Body" )
Set replyToUIDoc = ws.EditDocument(replyToDoc)
Call replyToUIDoc.Refresh(True)
End If
...
Axel
-
Hallo Axel,
Vielen Dank. Ich bin tatsächlich nicht weiter gekommen.
Das Script von dir macht aber Probleme!
Type mismatch on: DB in Zeile
Set replyToDoc = New NotesDocument(db)
Gruß
Thomas
-
Ist die Zeile
Dim db As Notesatabase
in deinem Code enthalten?
Poste bitte mal den gesamten Code.
Axel
-
Hallo!
Ich habe exakt das eingefügt wass du mir geschrieben hast.
habe es jetzt abgeändert:
Sub Click(Source As Button)
Dim replyToUIDoc As NotesUIDocument
Dim replyToDoc As NotesDocument
Dim stationeryDoc As NotesDocument
Dim stationeryBodyItem As NotesRichTextItem
Dim db As Notesdatabase
Set db = session.CurrentDatabase
Set collection = ws.Picklistcollection(PICKLIST_CUSTOM, False, db.server, db.filepath, "Stationery", "Select Stationery", "Please select stationery for new memo.")
Set stationeryDoc = collection.getfirstdocument
If Not stationeryDoc Is Nothing Then
Set replyToDoc = New NotesDocument(db)
replyToDoc.Form="Reply"
Set stationeryBodyItem = stationeryDoc.getfirstitem("Body")
Call replyToDoc.CopyItem( stationeryBodyItem, "Body" )
Set replyToUIDoc = ws.EditDocument(replyToDoc)
Call replyToUIDoc.Refresh(True)
End If
End Sub
Neuer Fehler beim starten der Aktion:
Variant does not contain an object
Gruß
Thomas
-
Mein Code war eigentlich nur als Ersatz für den Bereich der Anlage des neuen Dokumentes gedacht. Deine Dim - Anweisungen hättest du übernehmen sollen.
Hier dann noch mal der komplette Code:
Sub Click(Source As Button)
Dim ws As New NotesUIWorkspace
Dim session As New NotesSession
Dim db As NotesDatabase
Dim collection As notesdocumentcollection
Dim replyToUIDoc As NotesUIDocument
Dim replyToDoc As NotesDocument
Dim stationeryDoc As NotesDocument
Dim stationeryBodyItem As NotesRichTextItem
Set db = session.CurrentDatabase
Set collection = ws.Picklistcollection(PICKLIST_CUSTOM, False, db.server, db.filepath, "Stationery", "Select Stationery", "Please select stationery for new memo.")
Set stationeryDoc = collection.getfirstdocument
If Not stationeryDoc Is Nothing Then
Set replyToDoc = New NotesDocument(db)
replyToDoc.Form="Reply"
Set stationeryBodyItem = stationeryDoc.getfirstitem("Body")
Call replyToDoc.CopyItem( stationeryBodyItem, "Body" )
Set replyToUIDoc = ws.EditDocument(replyToDoc)
Call replyToUIDoc.Refresh(True)
End If
End Sub
Am besten fügst du bei allen Scripts in den [Options] - Abschnitt die Zeile
Option Declare
ein.
Dann kann es dir nicht passieren, dass du nicht deklarierte Variablen benutzt.
Axel
-
Hallo,
OK, habe ich gemacht.
Er ruft nun die Vorlagen auf.
Bei der Auswahl einer Vorlage mit oder ohne Anhang kommt folgende fehlermeldung.
Document command is not available
Vorlage wird nicht eingefügt.
Hast du da noch einen Vorschalag?
Gruß
Thomas
-
Sorry, ich hab' beim EditDocument den Parameter für den EditModus vergessen. Somit öffnet er das Dokument im Lesemodus und der Refresh fährt gegen die Wand.
....
Set stationeryBodyItem = stationeryDoc.getfirstitem("Body")
Call replyToDoc.CopyItem( stationeryBodyItem, "Body" )
Call replyToDoc.Save(True,Save) 'Temp. Speichern des Backend-Doc. damit RTF-Feld angezeigt wird.
Set replyToUIDoc = ws.EditDocument(True, replyToDoc)
Call replyToUIDoc.Refresh(True)
Call replyToDoc.Remove(True) 'Das Dokument, das im Backend erstellt wurde, löschen
....
Edit: Ich habe noch zwei Zeilen eingefügt, damit der Inhalt des RTF angezeigt wird.
Axel
-
Hallo axel,
eine Entschuldigung ist wirklich nicht nötig, so wie du mir hier hilfst.
Der Anhang und Text werden nun übernommen. Klasse
Leider werden Subject und Absender nicht übernommen.
Fehlt da noch was aus dem anderen script?
Gruß
Thomas
-
..
-
Hmm, dass könnte daran liegen, dass das Dokument jetzt im Backend erstellt wird und nicht mehr im Frontend mit ComposeDocument. Da muss jetzt noch was in den Code rein.
Woher kommen den Absender und Subject? Wahrscheinlich aus dem aktuellen Mail. Wo rufst du die Aktion auf? Ist eine Ansichtenaktion, oder eine Aktion im Dokument?
Axel
-
Also ich habe deinen Zusatz für RTF noch nicht drin.
Ich habe die Aktion zur Zeit nur im Ordner Inbox.
In der maske habe ich das gleiche Problem.
@Klaus: Der Zusatz hat nicht funktioniert.
Hier das aktuelle Script:
Sub Click(Source As Button)
Dim ws As New NotesUIWorkspace
Dim session As New NotesSession
Dim db As NotesDatabase
Dim collection As notesdocumentcollection
Dim replyToUIDoc As NotesUIDocument
Dim replyToDoc As NotesDocument
Dim stationeryDoc As NotesDocument
Dim stationeryBodyItem As NotesRichTextItem
Set db = session.CurrentDatabase
Set collection = ws.Picklistcollection(PICKLIST_CUSTOM, False, db.server, db.filepath, "Stationery", "Select Stationery", "Please select stationery for new memo.")
Set stationeryDoc = collection.getfirstdocument
If Not stationeryDoc Is Nothing Then
Set replyToDoc = New NotesDocument(db)
replyToDoc.Form="Reply"
Set stationeryBodyItem = stationeryDoc.getfirstitem("Body")
Call replyToDoc.CopyItem( stationeryBodyItem, "Body" )
Set replyToUIDoc = ws.EditDocument(True, replyToDoc)
Call replyToUIDoc.Refresh(True)
End If
End Sub
-
Für die Ansichtenaktion müsste es so aussehen:
Sub Click(Source As Button)
...
Dim mailcol As NotesDocumentCollection
Dim maildoc As NotesDocument
...
Set db = session.CurrentDatabase
Set mailcol = db.UnprocessedDocuments
If mailcol.Count = 0 Then
Messagebox "Sie haben keinen Eintrag markiert", 48, "Antwort erstellen"
Exit Sub
End If
If mailcol.Count > 1 Then
Messagebox "Sie haben mehr als einen Eintrag markiert", 48, "Antwort erstellen"
Exit Sub
End If
Set maildoc = mailcol.GetFirstDocument
....
....
Set replyToDoc = New NotesDocument(db)
replyToDoc.Form="Reply"
replytoDoc.Subject = maildoc.Subject
replytoDoc.SendTo = maildoc.From
....
....
End Sub
Für die Aktion innerhalb des Dokuments so:
Sub Click(Source As Button)
...
Dim mailuidoc As NotesUIDocument
Dim maildoc As NotesDocument
...
Set mailuidoc = ws.CurrentDocument
Set maildoc = mailuidoc.Document
....
....
Set replyToDoc = New NotesDocument(db)
replyToDoc.Form="Reply"
replytoDoc.Subject = maildoc.Subject
replytoDoc.SendTo = maildoc.From
....
....
End Sub
Axel
-
Hi,
also das schein alles nicht zu funktionieren.
Auch die RTF Speicher/Lösch - Änderung macht fehler. "Im Feld lässt sich nur Plain Text speichern.
Habe nun im Ordner INBOX eine Aktion stehen die so aussieht.
Anhang und Text werden allerdings hinter die Signatur gelegt. Ans Ende vom Dokument. Subjekt ist drin. Absenderadresse wird allerdings nicht ins to feld übergeben.
RTF-habe ich deaktiviert!
Sub Click(Source As Button)
Dim ws As New NotesUIWorkspace
Dim session As New NotesSession
Dim db As NotesDatabase
Dim collection As notesdocumentcollection
Dim replyToUIDoc As NotesUIDocument
Dim replyToDoc As NotesDocument
Dim stationeryDoc As NotesDocument
Dim stationeryBodyItem As NotesRichTextItem
Dim itm As NotesItem
Dim itm2 As NotesItem
Set db = session.CurrentDatabase
Set collection = ws.Picklistcollection(PICKLIST_CUSTOM, False, db.server, db.filepath, "Stationery", "Select Stationery", "Please select stationery for new memo.")
Set stationeryDoc = collection.getfirstdocument
If Not stationeryDoc Is Nothing Then
Set replyToDoc = New NotesDocument(db)
replyToDoc.Form="Reply"
Set stationeryBodyItem = stationeryDoc.getfirstitem("Body")
Call replyToDoc.CopyItem( stationeryBodyItem, "Body" )
Set itm = stationeryDoc.getfirstitem("Subject")
Call replyToDoc.CopyItem( itm, "Subject" )
Set itm2 = stationeryDoc.getfirstitem("From")
If Not itm2 Is Nothing Then
Call replyToDoc.CopyItem( itm2, "To" )
End If
'Call replyToDoc.Save(True,True) 'Temp. Speichern des Backend-Doc. damit RTF-Feld angezeigt wird.
Set replyToUIDoc = ws.EditDocument(True, replyToDoc)
Call replyToUIDoc.Refresh(True)
'Call replyToDoc.Remove(True) 'Das Dokument, das im Backend erstellt wurde, löschen
End If
End Sub
Die mail sieht dann so aus:
...............Signaturanfang.........
visit:http://www.XXXXXXXX.de
Geschäftsführer: XXXXXXXXXXX
Sitz der Gesellschaft: XXXX - Rechtsform: GmbH -
Amtsgericht XXXX - USt-ID-Nr. DE XXXXXXXXXXSehr geehrter Herr XXXXX,
sehr geehrter Herr XXXXXX,
um die Verfügbarkeit unserer Systeme noch zu verbessern
und den hohen Anforderungen heutiger Internettechnologien
auch zukünftig gerecht zu werden, wird die xxxxxxxxxxxxx bis
-
Hi,
also das schein alles nicht zu funktionieren.
Auch die RTF Speicher/Lösch - Änderung macht fehler. "Im Feld lässt sich nur Plain Text speichern.
RTF-habe ich deaktiviert!
Wenn du das im Feld deaktiviert hast, dann kannst du auch nur Text einfügen. Du musst das Feld zu einem RTF-Feld machen.
Ich frag jetzt nochmal: Woher kommen Subject und der Absender?
Axel
-
Hi,
Subject und Abdender kommen aus der mail auf die ich das Reply anwende.
Wegen RTF: Am Feld habe ich nichts deaktiviert oder geändert.
Ich habe nur die 2 Zeilen von dir im Script deaktiviert.
-
Subject und Abdender kommen aus der mail auf die ich das Reply anwende.
Habe nun im Ordner INBOX eine Aktion stehen die so aussieht.
Dann schau dir meine Antwort #14 an. Dort steht alles was du brauchst um die Abgaben aus dem markierten Mail in das Reply zu übernehmen.
Axel
-
Hallo !
OK verstehe ich!
Kannst du mir das ganze script für die Inbox Aktion hier reinschreiben.
Ich weiß nicht wo und wie ich deine änderungen ünernehmen muss.
Danke
Thomas
-
Sei mir nicht böse, aber so wird das nichts. Du solltest dich erstmal mit den Grundlagen der Programmierung vertraut machen. Ich kann dir zwar den gesamten Code hier reinstellen, aber ich habe keine Zeit ihn detailliert zu testen. Und da dir die Grundlagen fehlen, stehst du bei der erst besten Fehlermeldung wieder auf dem Schlauch.
Axel