Das Notes Forum
Domino 9 und frühere Versionen => Entwicklung => Thema gestartet von: robertpp am 02.07.04 - 08:33:43
-
Hallo,
Ich hab mir ein script gebastelt wenn ich es mit dem Scriptdebugger durchgehe dann ist das Attachment im Body-Field, sobald ich aber das Script ohne Debugger laufen lasse hängt das Attachment immer hinter der durchgezogenen Linie am Ende des doc's. Weiß jemand warum?
Sub Click(Source As Button)
Dim s As New NotesSession
Dim db As NotesDatabase
Dim maildb As NotesDatabase
Dim ws As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim doc As NotesDocument
Dim memo As NotesDocument
Dim RTItem As NotesRichtextItem
Dim mailf, server, tempDrive, Filepath As String
Dim attachArray() As String
tempDrive = "C:\temp"
Set db=s.CurrentDatabase
Set uidoc = ws.CurrentDocument
Set doc = uidoc.Document
If Dir$(tempDrive,16) = "" Then
dirflag="true"
Mkdir tempDrive
End If
Redim attachArray(0)
attachArray(0)="aecheckft.xls"
' attachArray(1)="aecheckro.xls"
Forall posi In attachArray
If posi ="" Then
Exit Forall
Else
' Msgbox (posi)
End If
End Forall
Forall Item In doc.Items
If ( Item.Type = RICHTEXT ) Then
If Not Isempty(Item.embeddedobjects) Then
Forall obj In Item.EmbeddedObjects
If ( obj.Type = EMBED_ATTACHMENT ) Then
Forall posi In attachArray
If(obj.Name = posi ) Then
Msgbox (posi + " = "+ obj.Name)
Call obj.ExtractFile ( tempDrive & "\" & obj.Source )
Filepath = tempDrive & "\" & obj.Source
mailf = s.GetEnvironmentString ("MailFile", True)
server = s.GetEnvironmentString ("MailServer", True)
Set maildb = New Notesdatabase (server, mailf)
Set memo = maildb.CreateDocument
memo.Form = "memo"
memo.Subject = "Änderungscheckliste " & doc.Project(0)
memo.SendTo = ""
' memo.Body = " "
' Set Item = memo.GetFirstItem( "Body" )
Set RTItem = New NotesRichTextItem( memo, "Body" )
Set object = RTItem.EmbedObject( EMBED_ATTACHMENT , "" , Filepath )
Call doc.Save( True , False )
doc.SaveOptions = "0"
Call ws.EditDocument (True, memo)
Kill Filepath
' Else
' Msgbox (posi +" Keine Übereinstimmung!")
End If
End Forall
End If
End Forall
End If
End If
End Forall
' Kill Filepath
End Sub
danke robert
-
Probier mal das Dokument memo zwischen
Set RTItem = New NotesRichTextItem( memo, "Body" )
und
Set object = RTItem.EmbedObject( EMBED_ATTACHMENT , "" , Filepath )
abzuspeichern.
-
das abspeichern bringt auch leider nix.
Hat sonst noch jemand eine lösung für das problem?
-
Genau das Problem hatte ich auch. Ich habe es dann letztendlich so gelöst:
In Script wird das Backenddokument erstellt, aber nicht das Rich Text Item. Ins Backend wird in das Feld FilePath der Pfad der anzuhängenden Datei und ein Flag Feld FlagInsertAttachment mit dem Wert "1" geschrieben.
Im Postopen der Maske Memo dann folgende @Formel:
@If(
FlagInsertAttachment = "1";
@Do(
@Command([EditGotoField];"Body");
@Command([EditInsertFileAttachment];FilePath);
@Command([FileSave])
);
""
)
Das Feld "FlagInsertAttachment" sollte bearbeitbar + versteckt sein und in der Eingabeumsetzung die Formel "0" haben.
Andreas
-
Das Problem dabei ist aber das ich mir ja die Mail-db jeden users öffne:
mailf = s.GetEnvironmentString ("MailFile", True) server = s.GetEnvironmentString ("MailServer", True)
Set maildb = New Notesdatabase (server, mailf)
Set memo = maildb.CreateDocument
und dort möchte ich nicht unbefingt ins postopen das eintragen.
Gibt es sonst noch eine möglichkeit?
-
mach mal folgendes am ende Deines Scripts
Call uidoc.save
Call uidoc.close
Call doc.save(True,True)
Exit Sub
-
Was sollte das bringen da mach ich ja nur das doc zu aber ich hab ja ein problem mit dem memo doc ??? ???
-
Ich meinte natürlich schon dein memo Dokument, aber Du hast das gar nicht im Frontend auf. Dann speichere doch mal das memo Dokumente und verzichte (nur temporär) auf den Befehl "Call ws.EditDocument (True, memo)", stehen die Anhänge dann im Feld drin?
-
Wie meinst du das ich "nur temporär" auf den befehl verzichten soll?
dann kann ich ja nicht kontrollieren ob das attachment im body drinnen ist wenn ich es nicht im forntend öffnen. Das Problem dabei, weil ich es im frontend öffnen muss ist, dass vorher noch kein absender feststeht!
-
Sorry, habe mich wohl etwas unverständlich ausgedrückt.
Ich meinte damit, das Du nach dem Abspeichern das Dokument nicht per Script öffnest sollst, sondern Testweise einfach mal von Hand.In "Alle Dokumente" in der Maildatenbank müßte das Dokument ja zu finden sein, und testet, ob die Anhänge dann auch nicht im Boby Feld stehen.
Ich hatte nämlich das gleiche Problem, allerdings hatte ich das Script in einer Maskenaktion des Maildokuments. Ich mußte aber, nachdem ich die Objecte angehängt hatte, erst das UIDOC speichern, dann schliessen, dann das doc Speichern und dann das UIDOC wieder öffnen. Damit hats bei mir dann geklappt.