so mal zum Anfangen.
dim uiws as new notesuiworkspace
dim safe as variant
%rem
safe = uiws.prompt(PROMPT_YESNO,"Safety First","Are you...")
if safe = 1 then
end if
safe:= @Prompt([YesNo];"Safety First";"Are you sure you want to set this document to active?");
@If(safe=1;
@Do(
@Command([EditDocument]);
@Do(@SetField("zeigestatus"; "active"));
@Do(@SetField("Author"; ""));
@Command([ViewRefreshFields]);
@Do(@Command([FileSave]);
FIELD SaveOptions := SaveOptions;
@SetField("SaveOptions";"0");
@MailSend( v_username ; add_berechtigte ; blindCopyTo ; "Your E-Mail address request" ; "Dear " +v_name ; "Für weitere Informationen klicken Sie bitte auf die Verknüpfung: "; [IncludeDoclink] : [Sign] ))
);
""
)
%endrem
Sieh dir mal die Notesuiworkspace und NotesuiDocument und NotesDocument Klassen an in der Designerhilfe
Soviel ich jetzt aus den Helpnotes lesen konnte sollte mein Script irgend wie so aussehen. Stimmt das ungefähr?
Dim ses As New NotesSession
Dim ndbCurrentDB As NotesDatabase
Dim docMailDocument As NotesDocument
Dim rtBody As NotesRichTextItem
Dim nSendto As NotesName
Set ndbCurrentDB = ses.CurrentDatabase
Set docMailDocument = New NotesDocument( ndbCurrentDB )
Set rtBody = docMailDocument.CreateRichTextItem( "Body" )
Set nSendto = ses.CreateName(sSendto)
'Set Fields for the Mail
docMailDocument.SendTo = v_name
docMailDocument.Subject = "Your Email request"
'Set Body Field for the Mail
Call rtBody.AppendText( "Guten Tag" )
Call rtBody.AddNewLine( 2 )
Call rtBody.AppendText( sMailtext )
Call rtBody.AddNewLine( 1)
Call rtBody.AppendDocLink( docRequestdoc, "Zum Antrag gehen")
Call rtBody.AppendText( " - Link zum Dokument" )
Call rtBody.AddNewLine( 2)
Call rtBody.AppendText( "Mit freundlichen Grüssen" )
Call rtBody.AddNewLine( 2 )
Call rtBody.AppendText(sOriginator )
'Send the Mail
Call docMailDocument.Send( True )
Hmm funktioniert irgend wie nicht. Diese beiden Fehler kommen.
wo werden den diese bieden Variabeln gesetzt?
Call rtBody.AppendDocLink( docRequestdoc, "Zum Antrag gehen")
docMailDocument.SendTo = v_name
Wir hauen doch nicht.... wir schiessen :-)
v_name ist immer noch leer
Set nSendto = ses.CreateName(sSendto) ist ein wenig komisch?
evtl. hilft dir folgendes
dim v_username as string
dim berechtigte as string
dim blindCopyTo as string
....
v_username = source.fieldgettext("v_username")
berechtigte = source.fieldgettext("berechtigte")
blindCopyTo = source.fieldgettext("blindCopyto")
...
...
docMailDocument.SendTo = v_username
docMailDocument.copyto = berechtigte
docMaildocument.BlindCopyTo = blindcopyto
....
set docRequestDoc = source.document
...
...
Ausserdem solltest du unter Options noch ein Option Declare einfügen. Damit entgehst Du eineigen der gröbsten Fehler....
Immer noch nicht ???
Dim uiws As New notesuiworkspace
Dim ses As New NotesSession
Dim ndbCurrentDB As NotesDatabase
Dim docMailDocument As NotesDocument
Dim rtBody As NotesRichTextItem
Dim nSendto As NotesName
Dim v_username As String
Dim blindCopyTo As String
v_username = source.fieldgettext("v_username")
Set ndbCurrentDB = ses.CurrentDatabase
Set docMailDocument = New NotesDocument( ndbCurrentDB )
Set rtBody = docMailDocument.CreateRichTextItem( "Body" )
Set nSendto = ses.CreateName(sSendto)
'Set Fields for the Mail
docMailDocument.SendTo = v_username
docMailDocument.Subject = "Your Email request"
Set docRequestDoc = source.document
'Set Body Field for the Mail
Call rtBody.AppendText( "Guten Tag" )
Call rtBody.AddNewLine( 2 )
Call rtBody.AppendText( sMailtext )
Call rtBody.AddNewLine( 1)
Call rtBody.AppendDocLink( docRequestdoc, "Zum Antrag gehen")
Call rtBody.AppendText( " - Link zum Dokument" )
Call rtBody.AddNewLine( 2)
Call rtBody.AppendText( "Mit freundlichen Grüssen" )
Call rtBody.AddNewLine( 2 )
Call rtBody.AppendText(sOriginator )
'Send the Mail
Call docMailDocument.Send( False )
@MailSend( antragsteller ; copyTo ; blindCopyTo ; "Your E-Mail address request" ; "Dear " +v_name ; "Für weitere Informationen klicken Sie bitte auf die Verknüpfung: "; [IncludeDoclink] : [Sign] );
Das klappt aber? Also da kommt kein Error und der Link wird auch geschickt.
ICh habe hier noch etwas anderes, dort kommt aber immer der Fehler ich rufe eine unbekannte Funktion auf. Bei den Scripts ist dieses File: lib20SendMail
Sub SendMail(sSendto As String, sSubject As String, sMailtext As String, _
docRequestdoc As NotesDocument, sOriginator As String)
Dim ses As New NotesSession
Dim ndbCurrentDB As NotesDatabase
Dim docMailDocument As NotesDocument
Dim rtBody As NotesRichTextItem
Dim nSendto As NotesName
Set ndbCurrentDB = ses.CurrentDatabase
Set docMailDocument = New NotesDocument( ndbCurrentDB )
Set rtBody = docMailDocument.CreateRichTextItem( "Body" )
Set nSendto = ses.CreateName(sSendto)
'Set Fields for the Mail
docMailDocument.SendTo = nSendto.Abbreviated
docMailDocument.Subject = sSubject
'Set Body Field for the Mail
Call rtBody.AppendText( "Guten Tag" )
Call rtBody.AddNewLine( 2 )
Call rtBody.AppendText( sMailtext )
Call rtBody.AddNewLine( 1)
Call rtBody.AppendDocLink( docRequestdoc, "Zum Antrag gehen")
Call rtBody.AppendText( " - Link zum Dokument" )
Call rtBody.AddNewLine( 2)
Call rtBody.AppendText( "Mit freundlichen Grüssen" )
Call rtBody.AddNewLine( 2 )
Call rtBody.AppendText(sOriginator )
'Send the Mail
Call docMailDocument.Send( False )
End Sub
Dann habe ich einen Button der das macht:
Sub Click(Source As Button)
Dim vReaders As Variant 'The Readers of the Document
Dim sSendto As String 'The Sendto part of the Mail
Dim sSubject As String 'The Subject of the Mail
Dim sMailtext As String 'The Text of the Mail
Dim sMailSender As String 'The Originator of the Mail
Dim uiws As New NotesUIWorkspace
Dim uidocCurrentDocument As NotesUIDocument
Dim ses As New NotesSession
Dim docCurrentDocument As NotesDocument
Dim nmDecisionMaker As NotesName
Dim itemReaders As NotesItem
Set uidocCurrentDocument = uiws.CurrentDocument
Set docCurrentDocument = uidocCurrentDocument.Document
Set nmDecisionMaker = New NotesName(ses.UserName )
Set itemReaders = docCurrentDocument .getfirstitem("rReaders")
'Goes shure that the Document is in the Edit mode
uidocCurrentDocument.EditMode = True
'Adds the Role of the Time Administrators to the Readers field
itemReaders.AppendToTextList("[TimeAdmin]")
'Is because the item is updated. it isn't possible to update the other fields without saving
Call uidocCurrentDocument.save
'Setting the Fields
Call uidocCurrentDocument.FieldSetText("nmDecisionOf",Cstr(nmDecisionMaker.Abbreviated))
Call uidocCurrentDocument.FieldSetText("dtDecisiondate", Cstr(Now))
Call uidocCurrentDocument.FieldSetText("tStatus", "Genehmigt")
Call uidocCurrentdocument.fieldsettext("aAuthors","[DBAdmin] ; [TimeAdmin]")
Call uidocCurrentDocument.save
'Sets the Variables to send the mail
sSendto = Cstr(uidocCurrentDocument.FieldGetText("nmOriginator"))
sSubject = "Ihr Antrag wurde bestätigt"
sMailtext = "Ihr Antrag wurde genehmigt. Anbei noch den Link zu ihrem Antrag."
sMailSender = nmDecisionMaker.Common
Call SendMail(sSendto , sSubject , sMailtext, docCurrentDocument, sMailsender)
'Goes shure that the user isn't asket if he wants to save and saves the Document
Call uidocCurrentDocument.FieldSetText("SaveOptions", "0")
Call uidocCurrentDocument.Close
End Sub
Dabei kommt der Fehler beim Button:
Not a sub or function name: SENDMAIL
So jetzt wird es doch nochmal mysteriös. Ich habe einen Button der diese Formel hat:
safe:= @Prompt([YesNo];"Safety First";"Are you sure you want to decline this request?");
@If(safe=1;
@Do(
@Command([EditDocument]);
@Do(@SetField("zeigestatus"; "declined"));
@Do(@SetField("Author"; ""));
@Command([ViewRefreshFields]);
@Do(@Command([FileSave]))
);
""
)
Funktioniert wunderbar. Im querysave habe ich dann den Mailcode
If Source.FieldGetText("zeigestatus") = "declined" Then
If Source.FieldGetText("ablehnungsgrund") = "" Then
source.GotoField("ablehnungsgrund")
Messagebox "Decline reason field is empty", 0 + 48, "Failure"
Continue = False
Exit Sub
End If
Dim vReaders As Variant 'The Readers of the Document
Dim sSendto As String 'The Sendto part of the Mail
Dim sSubject As String 'The Subject of the Mail
Dim sMailtext As String 'The Text of the Mail
Dim sMailSender As String 'The Originator of the Mail
Dim uiws As New NotesUIWorkspace
Dim uidocCurrentDocument As NotesUIDocument
Dim ses As New NotesSession
Dim docCurrentDocument As NotesDocument
Dim nmDecisionMaker As NotesName
Dim itemReaders As NotesItem
Set uidocCurrentDocument = uiws.CurrentDocument
Set docCurrentDocument = uidocCurrentDocument.Document
sSendto = Cstr(uidocCurrentDocument.FieldGetText("v_username"))
sSubject = "Ihr Antrag wurde bestätigt"
sMailtext = "Ihr Antrag wurde genehmigt. Anbei noch den Link zu ihrem Antrag."
sMailSender = Cstr(uidocCurrentDocument.FieldGetText("v_username"))
Call SendMail(sSendto , sSubject , sMailtext, docCurrentDocument, sMailsender)
Call uidocCurrentDocument.FieldSetText("SaveOptions", "0")
Call uidocCurrentDocument.Close
End If
Das Mail wird mir auch geschickt, das heisst der Status ist also eine zeit lang auf declined. Das Dokument wird aber nicht mit dem neuen Status gespeichert sondern wieder mit dem alten, also als Request.