I need to add code to the send mail button in the mail template that unfortunately needs to be written in LotusScript (long story). Anyone have any ideas of to how to simulate the following in script?
MEMO_SEND := “1024”;
FIELD ActionInProgress := MEMO_SEND;
@If(@Command([FileSave]); @Command([FileCloseWindow]); @Return(“”))
It looks easy…but I cannot seem to simulate the last line in script. Any ideas?
Thanks in advance!
Subject: How to write the send mail button in script?
Are you saying that you currently are using the built-in send mail on save form action? Or, do you have a custom button that runs the code you provided? Your code snippet doesn’t actually send the document (unless I’m missing something). Anyway, to send an email via script your code would look something like this
dim session as New NotesSession
dim ws as New NotesUIWorkspace
dim db as NotesDatabase
dim uidoc as NotesUIDocument
dim doc as NotesDocument. mailDoc as NotesDocument
const MEMO_SEND = “1024”
set db = session.CurrentDatabase
set uidoc = ws.CurrentDocument
set doc = uidoc.Document
doc.ActionInProgress = MEMO_SEND
if(doc.Save(true, true)) then
call uidoc.Close
end if
set mailDoc = db.CreateDocument
mailDoc.Form = “Memo”
mailDoc.Subjet = “put your email subject here”
mailDoc.Body = “this is the body of your message”
call mailDoc.Send(false, “recipient name”)
Of course, I may have misunderstood your requirements. If you need more help, send me an email.
Subject: RE: How to write the send mail button in script?
I think that code that I posted is out of the box functionality. When I try to send it…the document is sent…but I also get a box that states:
Do you want to save, send, or discard your changes? Choose cancel to continue editing
There are buttons after that to save, send, discard and cancel
Apparently I am missing the call to the dll or something that will bypass that box…but I am not certain on that.
Below is my code that is trying to duplicate this…let me know if you need any more information:
doc.ActionInProgress = MEMO_SEND
If(doc.Save(True, True)) Then
Call doc.Send(False, doc.EnterSendTo(0))
Call uidoc.Close
End If
Subject: RE: How to write the send mail button in script?
You can skip the Recipients parameter in the Send – it’s only used when there are no SendTo, CopyTo or BlindCopyTo values. Once the document has been saved and sent, you can set doc.MailOptions and doc.SaveOptions to “0” to avoid the dialogs when you close the UI document.
Subject: RE: How to write the send mail button in script?
Thanks Stan…I got it to bypass that message…here is hopefully my last 2 questions…
-
The message is being saved as a draft every time I send the mail. Is there a way to prevent this from occurring?
-
If a user automatically saves every document that they send…will this code save it in their sent folder? I do not have mine set to automatically save every e-mail…so…I cannot tell if it will.
Here is my revised code:
doc.ActionInProgress = MEMO_SEND
doc.MailOptions = “0”
doc.SaveOptions = “0”
If(doc.Save(True, True)) Then
Call Doc.Send(False)
Call uidoc.Close
End If
Thanks again for all of your help.
Subject: I got it
I figured out what I needed to do…I needed to call the QuerySave code of the CoreEmail class. My code now looks like the following:
Continue = True
Call uidoc.FieldSetText(“useApplet”, “True”)
Call cMemoObject.QuerySave(Continue)
If continue = True Then
Call uidoc.Close
End If
In the options area I have the following:
Use “CoreEmailClasses”
Thanks for all of your help.