Das Notes Forum
Domino 9 und frühere Versionen => Entwicklung => Thema gestartet von: robertpp am 28.02.03 - 08:16:50
-
Hallo,
Ich möchte einen Agent erstellen der mir ein Doc versendet. Mein jetztiger Stand ist:
Dim s As New NotesSession
Dim db As NotesDatabase
Dim uiws As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim doc As NotesDocument
Dim rtfBody As NotesRichTextItem
Dim fpath(0) As Variant
Set db= s.CurrentDatabase
Set doc = New NotesDocument(db)
Set uidoc = uiws.CurrentDocument
If uidoc.FieldGetText( "Subject" ) = "Umsatz Weikersdorf" Then
doc.Form = "Memo"
doc.SendTo = "Robert Prinz\MISEBG"
doc.Subject = "Umsatz Weikersdorf"
Set rtfBody = doc.CreateRichTextItem( "Body" )
fpath(0) = "C:\mappe2.xls"
uidoc.gotofield("Body")
Call uidoc.CreateObject("Body", "", fpath(0))
Call doc.Save(True, False)
Call doc.Send( True )
Call doc.Remove(True)
Exit Sub
End If
Mein Problem liegt aber bei den Fettgedruckten Zeilen!!!
Wie kann ich CreateObject hier ausführen?
Dieser Befehl geht ja nur bei uidoc's aber ich sprech das ganze ja mit doc an!!!!!
gotofield macht ebenfalls probleme!!!
Bitte um Hilfe
robertpp
-
Das Problem bei dieser Sache ist:
Wenn ich es nach meiner Variante mache:
Call uidoc.CreateObject("Body", "", fpath(0))
(Das ich in einer anderen DB verwende) dann wird das Excelfile als geöffnetes File eingefügt und genau das brauch ich!!!
robertpp
-
... da muss ich leider passen :'(
-
hi robert,
setz mal folgende zeile oben rein:
set uidoc = ws.editdocument(true, doc)
tschö
-
Ich hab das jetzt eingefügt unter:
Dim s As New NotesSession
Dim db As NotesDatabase
Dim uiws As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim doc As NotesDocument
Dim rtfBody As NotesRichTextItem
Dim fpath(0) As Variant
Set db= s.CurrentDatabase
Set doc = New NotesDocument(db)
Set uidoc = uiws.CurrentDocument
If uidoc.FieldGetText( "Subject" ) = "Umsatz Weikersdorf" Then
set uidoc = ws.editdocument(true, doc)
doc.Form = "Memo"
doc.SendTo = "Robert Prinz\MISEBG"
doc.Subject = "Umsatz Weikersdorf"
Set rtfBody = doc.CreateRichTextItem( "Body" )
fpath(0) = "C:\mappe2.xls"
uidoc.gotofield("Body")
Call uidoc.CreateObject("Body", "", fpath(0))
Call doc.Save(True, False)
Call doc.Send( True )
Call doc.Remove(True)
Exit Sub
End If
ich bekomm jetzt ein mail aber da fehlt der offene anhang!!!
Was macht der befehl genau?
Ich glaub es ist aber trotzdem der richtige ansatz!!
nur er sendet mir jetzt nicht das doc mit anhang weil das sehe ich dann noch immer ab bildschirm sondern er sendet mir ein neu erstelltes doc wo nix drinnen steht!!!
robertpp
-
... ws. <--- ist nicht definiert ;D
-
... ws. <--- ist nicht definiert ;D
war ein schreib fehler von mir. ich habs nur vom forum kopiert!!!
in der DB ist es richtig!!!
-
hallo robert,
ich denke wie folgt, müsste das gehen...
If uidoc.FieldGetText( "Subject" ) = "Umsatz Weikersdorf" Then
doc.Form = "Memo"
doc.SendTo = "Robert Prinz\MISEBG"
doc.Subject = "Umsatz Weikersdorf2
Set rtfBody = doc.CreateRichTextItem( "Body" )
Call doc.Save(True, False)
dim muidoc as notesuidocument
set muidoc = ws.editdocument(true, doc)
fpath(0) = "C:\mappe2.xls"
muidoc.gotofield("Body")
Call muidoc.CreateObject("Body", "", fpath(0))
call muidoc.save
Call doc.Send( True )
Call doc.Remove(True)
Exit Sub
End If
-
Leider:
Gleicher Fehler wie davor!!
Er schickt mir ein Mail ohne Anhang und das was er mir senden sollte mit anhang sehe ich immer noch am bildschirm in der anderen datenbank und wenn ich dort auf senden klicke dann bekomm ich erst das richtige mail
Weiß dazu jemand eine lösung!!
Ich glaub es ist nur ein kleines problem!! Für einen Profi wahrscheinlich garkein problem!!!
robertpp
-
Es funkt jetzt aber wie bekomm ich am schluss das uidoc1 wieder zu und wie lösch ich es dann weil das doc1.remove(true) geht nicht.
Set db= s.CurrentDatabase
Set doc1 = New NotesDocument(db)
Set uidoc = uiws.CurrentDocument
If uidoc.FieldGetText( "Subject" ) = "Umsatz Weikersdorf" Then
doc1.Form = "Memo"
doc1.SendTo = "Robert Prinz/MISEBG"
doc1.Subject = "Umsatz Weikersdorf"
Set rtfBody = doc1.CreateRichTextItem( "Body" )
Call doc1.Save(True, False)
Set uidoc1 = uiws.editdocument(True, doc1)
fpath(0) = "S:\EIS\Berichte\Weikersdorf\Umsatz_Weikersdorf.xls"
uidoc1.gotofield("Body")
Call uidoc1.CreateObject("Body", "", fpath(0))
Call uidoc1.send
Call uidoc1.save
Call doc1.Remove(True)
Exit Sub
End If
robertpp
-
das frontenddokument kriegst du mit uidoc.close wieder geschlossen.
wenn das dokument im frontend geschlossen ist, müsstest du das dokument im backend löschen können.
tschö
-
Mein Endprodukt sieht jetzt so aus:
Sub Initialize
Dim s As New NotesSession
Dim db As NotesDatabase
Dim uiws As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim doc As NotesDocument
Dim doc1 As NotesDocument
Dim rtfBody As NotesRichTextItem
Dim fpath(0) As Variant
Dim Frage As Variant
Set db= s.CurrentDatabase
Set doc1 = New NotesDocument(db)
Dim view As NotesView
Set view = db.GetView("($Inbox)")
Set doc = view.GetFirstDocument
Frage = doc.Subject
If Frage(0) = "Umsatz Weikersdorf" Then
doc1.Form = "Memo"
doc1.SendTo = "Robert Prinz/MISEBG"
doc1.Subject = "Umsatz Weikersdorf"
Set rtfBody = doc1.CreateRichTextItem( "Body" )
Call doc1.Save(True, False)
Set uidoc = uiws.editdocument(True, doc1)
fpath(0) = "S:\EIS\Berichte\Weikersdorf\Umsatz_Weikersdorf.xls"
uidoc.gotofield("Body")
Call uidoc.CreateObject("Body", "", fpath(0))
Call uidoc.send
Call uidoc.save
Call uidoc.close
Call doc1.Remove(True)
End If
End Sub
Das sollte jetzt alles als Angent in einer MailDB laufen "nach eingang neuer mails" nur es geht net!!!!!!!!
Wenn ich den Agent im Designer "Starte" dann sendet er mir das mail wenn ich aber ein doc an die MailDB sende dann tut sich garnichts?
Jetzt bin ich ganz verzweifelt!!!
War die ganze arbeit um sonst oder hab ich nur einen Fehler gemacht?
robertpp
-
ich habe den Thread nur flüchtig überlesen, aber Du kannst definitiv keine Front End Klassen (zB ws.editdoc....) in einem Agent verwenden, der vom Server getriggered wird, in dem Fall bei Eingang neuer Mail.
Daher klappt es auch, wenn Du den Agent manuell startest, da sind wieder UI-Klassen erlaubt.
Nicht im Backend!!! Sorry :'(
Evtl. die Langsamen unter uns: was willst Du mit dem File und Versenden konkret?
Soll eine Datei in ein Mail angehangen und dann versendet werden?
Oder soll eine eingehende Mail mit einem Anhang bestückt werden? (*hrmp..ein schelm wer böses denkt... ;D ;D ;D*)
-
In der MailDB soll, wenn ein eMail mit "Subject"= "Umsatz Weikersdorf" einlangt, ein mail an andere Personen verschickt werden und einen Anhang erhalten!!! Aber der Anhang(xls) soll nicht als datei angehängt werden sondern soll sofort zum lesen sein!!! So wie in meinem beispiel!!!
robertpp
-
sorry, daß ich so dämlich frage...was meinst Du mit "gleich Lesen"..stehe auf der Leitung?
-
Wenn du eine datei anhängst dann muss du erst doppelt auf die datei klicken und dann starten sagen und dann wird die datei im excel geöffnet!!!
Mit dem Script von mir wir die datei direkt im mail geöffnet das heißt im RTFeld kannst du lesen was in der exceldatei steht!!!
Ist das jetzt gut beschrieben?
robertpp
-
ok, in meiner Sprache heißt das OLE Link..gut..dann laß mich etwas wursteln (prügel mich in den Untiefen der Busytime, des Schedul Managers, der Ressourc DB und Free Tim Search herum)...
hier schon mal was zum Lesen für Dich mit einer Backendklasse, die das kann, was Du gerne mit UI KLassen momentan machst und das dann nicht geht...also ein Ausweg:
EmbedObject method
Beispiel
Given the name of a file or an application, does one of the following:
Attaches the file you specify to a rich-text item.
Embeds an object in a rich-text item. The object is created using either the application or the file you specify.
Places an object link in a rich-text item. The link is created using the file you specify.
Hinweis EmbedObject is not supported on OS/2, on UNIX, and on the Macintosh.
Defined in
NotesRichTextItem
Syntax
Set notesEmbeddedObject = notesRichTextItem.EmbedObject( type%, class$, source$, [ name$ ] )
Parameters
type%
Constant. Indicates if you want to create an attachment, an embedded object, or a object link. May be any of the following:
EMBED_ATTACHMENT (1454)
EMBED_OBJECT (1453)
EMBED_OBJECTLINK (1452)
Hinweis The above constants are also used with the Type property in the NotesEmbeddedObject class.
class$
String.
If you are using EMBED_OBJECT and want to create an empty embedded object from an application, use this parameter to specify the name of the application (for example, "1-2-3 Worksheet") and specify an empty string ("") for source$. Case-sensitive.
If you are using EMBED_OBJECTLINK or EMBED_ATTACHMENT, specify an empty string ("").
source$
String.
If you are using EMBED_OBJECT and want to create an embedded object from a file, use this parameter to specify the name of the file, and specify an empty string ("") for class$.
If you are using EMBED_ATTACHMENT or EMBED_OBJECTLINK, use this parameter to specify the name of the file to attach or link.
name$
String. Optional. Name by which you can reference the NotesEmbeddedObject later. This parameter is only used for OLE/2 objects and does not include attachments.
Return value
notesEmbeddedObject
The newly attached file, embedded object, or linked object.
Usage
For this method to work you must set a default view in the database.
Files can be attached on any Notes platform, but objects and links can only be created on platforms supporting OLE.
Files can be embedded as OLE/2 objects only on platforms supporting OLE, but they can be embedded as OLE/1 objects on any Notes platform (if the file is of a supported type, such as a Lotus® application data file).
Beispiel
Siehe auch
EmbeddedObjects property (in NotesDocument)
EmbeddedObjects property (in NotesRichTextItem)
GetAttachment method (in NotesDocument)
GetEmbeddedObject method
HasEmbedded property (in NotesDocument)
NotesEmbeddedObject class
Working with a rich-text item
-
dazu die Bsp:
This script is identical to the one above, except that it creates an embedded object using the file JIM.SAM.
Dim session As New NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim rtitem As NotesRichTextItem
Dim object As NotesEmbeddedObject
Set db = session.CurrentDatabase
Set doc = New NotesDocument( db )
Set rtitem = New NotesRichTextItem( doc, "Body" )
Set object = rtitem.EmbedObject _
( EMBED_OBJECT, "", "c:\jim.sam")
doc.Form = "Main Topic"
doc.Subject = _
"Here's Jim's document, as an embedded object"
Call doc.Save( True, True )
3. This script is identical to the one above, except that it creates an object link using the file JIM.SAM.
Dim session As New NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim rtitem As NotesRichTextItem
Dim object As NotesEmbeddedObject
Set db = session.CurrentDatabase
Set doc = New NotesDocument( db )
Set rtitem = New NotesRichTextItem( doc, "Body" )
Set object = rtitem.EmbedObject _
( EMBED_OBJECTLINK, "", "c:\jim.sam")
doc.Form = "Main Topic"
doc.Subject = "Here's Jim's document, as an object link"
Call doc.Save( True, True )
4. This script embeds a new, blank embedded object in the Body item of a document. The object is created using 1-2-3.
Dim session As New NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim rtitem As NotesRichTextItem
Dim object As NotesEmbeddedObject
Set db = session.CurrentDatabase
Set doc = New NotesDocument( db )
Set rtitem = New NotesRichTextItem( doc, "Body" )
Set object = rtitem.EmbedObject _
( EMBED_OBJECT, "1-2-3 Worksheet", "", _
"Quarterly Report" )
Call doc.Save( True, True )
-
OK ab jetzt heißt das bei mir auch OLE Link.. ich schau mir mal das an was du mir geschickt hast und vielleicht findest ja du dann noch die perfekte lösung für mein problem!!!
robertpp
-
eigentlich brauchst Du nur das Beispiel mit
dem Set object = rtitem.EmbedObject ( EMBED_OBJECT, "", "c:\jim.sam") abzutippeln und einzubauen (klar, incl., dem Ansprechen des RT Feldes per Script)
-
Das ist leider nicht das was ich brauche weil hier hängt er mir wieder die datei an und dann muss ich wieder die datei anklicken und sie öffnet sich dann wieder im excel!!
hast du mein script ausprobiert?
dort siehst du das die exceldatei direkt im notes drin steht!
oder hab ich dich jetzt falsch verstanden?
robertpp
-
Geduld..ich kann nicht jetzt
-
@robertpp
das OLE Objekt wie du es haben willst, das es offen ist beim Betrachter geht nur im frontend document, wenn du das im agent machst kann nur ein backend Objekt erzeugt werden d.h. es wird nur ein Icon im rtf Feld dargestellt.
cu
-
Lässt sich das anderes lösen damit ich zum gleichen Ergebnis komme?
robertpp
-
- das gleiche Ergebnis zu erzielen mit einer anderen Lösung habe ich nicht parat.
cu
-
@rob Green
Hast du eine lösung für mein problem gefunden?
robertpp
-
leider das Gleiche Ergebnis wie bei performance (war nicht anders zu erwarten). Das Problem ist auch massig aus LDD zu finden in den Foren..niemand hat ne Lösung außer externen Anbietern mit Zusatzprodukten. sorry