Also, in einfache Version sieht der Script so aus:
Dim ws As NotesUIWorkspace
Dim s As NotesSession
Dim db As NotesDatabase
Dim dbMail As NotesDatabase
Dim uidb As NotesDatabase
Dim uiDocA As NotesUIDocument
Dim docA As NotesDocument
Dim uiDocM As NotesUIDocument
Dim docM As NotesDocument
Dim tmpSubject As String
Dim rtitemA As NotesRichTextItem
Dim object As NotesEmbeddedObject
Dim body As NotesRichTextItem
'Kaufmännischer Ansprechpartner
Dim tmpAPK_EMail As String 'Email
Dim tmpAPK_Salutation As String 'Anrede
Dim tmpAPK_LastName As String 'Nachname
Dim tmpAnrede As String
Dim tmpText As String
Dim tmpBody As Variant
Dim tmpSAPNr As String
Dim user As String 'aktueller User
Dim cName As String
Dim tmpDatum As String 'aktuelles Datum
Dim tmpZeit As String 'akeuelle Zeit (hh:mm)
Dim tmpDatumZeit As String 'aktuelles Datum undZeit
Dim tmpDatumZeitName As String
Dim tmpTextHistory As String
Dim tmpHistory As String
Sub Initialize
Set s = New NotesSession
Set ws = New NotesUIWorkspace
Set uidb = s.CurrentDatabase 'aktuelle Anwendung "Workflow Angebot"
Set uiDocA = ws.CurrentDocument 'aktuell geöffnete Anbebot-Dokument
uiDocA.Editmode = True
Call uiDocA.Refresh
Call uiDocA.Save
Set docA = uiDocA.Document
user = s.UserName
cName = s.CommonUserName
tmpDatum= Format(Now, "Short Date") 'Aktuelles Datum
tmpZeit = Format(Now, "Short Time") 'Aktuelle Zeit
tmpDatumZeit = tmpDatum & " " & tmpZeit 'Aktuelle TT.MM.JJJJ hh:mm
tmpDatumZeitName = tmpDatum & " " & tmpZeit & " " & cName & Chr(13)
tmpTextHistory = tmpDatumZeit & ": Mail-Angebot versendet von " & cName
tmpHistory = tmpTextHistory & Chr(13) & uiDocA.FieldGetText("history")
docA.history = tmpHistory
tmpAPK_EMail = uiDocA.FieldGetText("APK_EMail")
tmpAPK_Salutation = uiDocA.FieldGetText("APK_Salutation")
tmpAPK_LastName = uiDocA.FieldGetText("APK_LastName")
tmpSAPNr = uiDocA.FieldGetText("SAPNr")
If tmpAPK_Salutation = "Frau" Then
tmpAnrede = "Sehr geehrte Frau " & tmpAPK_LastName & ","
ElseIf tmpAPK_Salutation = "Herr" Then
tmpAnrede = "Sehr geehrter Herr " & tmpAPK_LastName & ","
End If
tmpText = "anbei finden Sie unser Angebot " & tmpSAPNr
tmpSubject = "Angebot " & tmpSAPNr
If docA.Hasembedded Then
Set rtitemA = docA.GetFirstItem("Kunde_Angebot")
End If
Call Erstellen()
End Sub
Function Erstellen()
Dim mailDb As NotesDatabase
Dim docM As NotesDocument
Dim uidoc As NotesUIDocument
Dim msgStr As String
Set mailDb = New NotesDatabase( "", "" )
Call mailDb.OpenMail
Set docM = New NotesDocument( mailDb )
docM.Form = "Memo"
docM.Subject = tmpSubject
docM.EnterSendTo = tmpAPK_EMail
If Not rtitemA Is Nothing Then
If (rtitemA.Type = RICHTEXT ) Then
If Not IsEmpty(rtitemA.EmbeddedObjects) Then
ForAll object In rtitemA.EmbeddedObjects
If ( object.Type = EMBED_ATTACHMENT ) Then
Call rtitemA.CopyItemToDocument( docM, "Body" )
Exit ForAll
End If
End ForAll
End If
End If
End If
If False Then
Call body.AppendText( tmpAnrede )
Call body.AddNewLine( 2 )
Call body.AppendText( tmpText )
End If
Set uidoc = ws.Editdocument(True, docM)
Call uidoc.GotoField( "Body" )
msgStr = tmpAnrede & Chr(10) & Chr(10)
msgStr = msgStr & tmpText & Chr(10) & Chr(10)
Call uidoc.InsertText( msgStr )
Call docA.Save(True, True)
End Function
In diesem Version wird Information in dem Feld „history“ auf jedem Fall gespeichert, unabhängig davon hat der User Mail versendet oder nicht.
Ich brauche, dass den Befehl
Call docA.Save(True, True)
wird nur dann ausgeführt, wenn der User Mail versendet hat. In Formula Language kann man mit @if(@MailSend.... ) das machen. Gibt es eine Analog auch in LotusScript?
irgenwas wie if uidoc.send….