Research results about CancelSendOnMissingKey

When I write LotusScript in Domino Designer, there are some methods and properties that appear in Code Assistant but don't have help document.
I will write about research results one of them, that the CancelSendOnMissingKey property of the NotesSession class, in this time.

** In addition, this property is a function added in Version 10.


1.Syntax

As shown below to display to the syntax for methods and property by use Code Assistant.
code assistant
According to this, the property syntax is below.   
Data typeBoolean
To getflag = notesDocument.CancelSendOnMissingKey
To setnotesDocument.CancelSendOnMissingKey = flag
Legal ValuesTrue or False


2.Default value

Since this is a property, it has default value.
As described in the syntax, this property data type is boolean that the default value is true or false.
Also, this is a property of NotesDocument class, then that must be also considered by about Notes document.
It is the case of new and exist one.
Let's examine about default value both new and exist one.
I created the sample code below.

Sub Click( Source As Button )
  On Error GoTo ErrProc
  
  Dim session    As New NotesSession
  Dim dbCurrent  As     NotesDatabase
  Dim vwMailSend As     NotesView
  Dim docNew     As     NotesDocument
  Dim docExist   As     NotesDocument
  
  Set dbCurrent  = session.CurrentDatabase
  Set vwMailSend = dbCurrent.GetView( "your view name" )
  
  Set docNew = dbCurrent.CreateDocument
  MsgBox docNew.CancelSendOnMissingKey, 0 + 64, "Default value for new document"
  
  Set docExist = vwMailSend.GetFirstDocument()
  MsgBox docExist.CancelSendOnMissingKey, 0 + 64, "Default value for existing document"
  
  Exit Sub
  
ErrProc:
  MsgBox _
  "Error Line:    " & CStr(Erl) & Chr$(10) & _
  "Error Number : " & CStr(Err) & Chr$(10) & _
  "Error Content: " & Error, _
  0 + 16, "Mail send test"
  
  Exit Sub
End Sub


The result of doing is below.
result of new document
result of exist document
Apparently, the default values always may be False.

3.Sample code

What will happen if it will be changed this value to True?
I guess from the property name that it is related to sending email.
So, I created sample code below.
Sub subMailSendTest
  On Error GoTo ErrProc
  
  Dim session    As New NotesSession
  Dim dbCurrent  As     NotesDatabase
  Dim vwMailSend As     NotesView
  Dim docNew     As     NotesDocument
  
  Set dbCurrent  = session.CurrentDatabase
  Set vwMailSend = dbCurrent.GetView( "vwMailSend" )
  
  Set docNew = dbCurrent.CreateDocument
  
  Call docNew.ReplaceItemValue( "Form", "Memo" )
  Call docNew.ReplaceItemValue( "Subject", "Created by LotusScript " + CStr(Now) )
  Call docNew.ReplaceItemValue( "SendTo", "Masahiko Miyo/EFFECT-FORCE )
  
  docNew.CancelSendOnMissingKey = True
  
  Call docNew.Send( False )
  
  Exit Sub
  
ErrProc:
  MsgBox _
  "Error Line:    " & CStr(Erl) & Chr$(10) & _
  "Error Number : " & CStr(Err) & Chr$(10) & _
  "Error Content: " & Error, _
  0 + 16, "Mail send test"
  
  Exit Sub
End Sub


When I ran it, it is displayed the following error.
Error occured

Apparently, that prevents me from sending mail.

incidentally, after that I created the other sample code.
The code is change to property to True and save the Notes document.
When I ran it, it was saved successfully.


4.How to use this property

As checked above, if set True to property to fail sending an email.
It is better idea to use this property for input check on screen or business logic check.
But Error number is 4000 of general error number, it is not easier to distinguish it from other errors.
I want to that is should to assign another error number.


5.Conclusion

In the sample code I mentioned that it could be used for error distinguish it when sending email.
But maybe it is not correct how to use.
Please teach me if anyone knows about this function.






That’s all. Thank you for reading.



Notes/Dominoで困ったことがあれば、弊社にお問い合わせください。
HCL Ambassadorの私が承ります!
お問い合わせはこちらから→Lotus Notes/Domino カスタマイズとセキュリティ強化 - 株式会社エフ

コメント