#MailSend not working for one user when document is created from another database - lotus-notes

Mail comes into a mail-in database. In that database is an agent that creates a document
Set docIITS = dbIITS.CreateDocument
With docIITS
.form = "Informal Inquiry"
.subject = doc.subject(0)
'.sendTo = doc.from
.status="Open"
.. other fields
.save False,False
End With
and then calls
Call ws.EditDocument(True,docIITS,,,,True)
which shows the user the new document created in the other database. On that form is an action:
remark:=#If(instructions="";"Please respond to this as soon as possible.";instructions);
#If(status !="Closed" & AssignedTo !="";#MailSend(assignedto;"";"";"Informal Inquiry: " + area + " " + Type; remark;"";[IncludeDoclink]);"");
tmpActivity_log:=#If(status !="Closed" & AssignedTo !="";"**** " + #Name([CN];#UserName) + " sent notification to " + #Name([CN];assignedto) + " at " + #Text(#Now) + #NewLine + activity_log; activity_log);
FIELD activity_log:=tmpActivity_log;
#Command([FileSave]);
#Command([FileCloseWindow])
Recently one user has had the problem where the #MailSend() fails. No errors, just the mail doesn't get sent. The field activity_log does get updated and the document saved. If she closes the document and then reopens it from the second database, #MailSend() works as expected.
I created new databases using the designs of these two as templates. It doesn't matter whether she used the original or the copy of the first (mail-in) database, if the new document is created in the production second database, #MailSend fails. It doesn't matter whether she used the original or the copy of the first (mail-in) database, if the new document is created in the test copy of the second database, #MailSend succeeds. The second database has both a default form and a default view. And this worked for that same user a couple months ago. Any ideas what might be wrong or how to isolate the problem?

Is Notes used for other mail, or only for mail from this application? It's an action, so it runs in the user's Notes client. I'm thinking that there's something wrong with the user's client configuration -- e.g., wrong location document is selected, so mail is going into the local mail.box instead of the server's mail.box. If Notes isn't being used for other email, it would be easy to not notice this.

Related

How to modify result of #Formula ComposeWithReference in fresh new notesuidocument

I am modifying the mail9.ntf, in order to have User A answer to create a response to an email, on behalf of a generic user (owner B) of the mail file.
When composing a response to an email, the template use the following code:
REM {Notes Style Reply with History};
tmp:=From;
#SetEnvironment("fwdID"; #NoteID);
#Command([ComposeWithReference];"":"";"Memo"; 23 + 64);
Its works OK, but:
if there was an attachment in the original email, the following sentence is added:
[attachment "MyAttachment.odt" deleted by User A/MyDomain]
Server Domino 9.0.1FP10 - Notes 9.0.1FP7.
I tried to use the postopen event in order to use the Source notesuidocument to parse the body field and retrieve the line:
[attachment "MyAttachment.odt" deleted by User A/MyDomain]
but:
at this stage (new document, berver saved before), notesuidocument do not contains anything.
Source.getfieldText("body") return nothing
I do not have an fhandle on the contains.
I expect to be able to remove part of the new composed message from the body field.
I believe that the flag value of 16 is designed explicitly so the user can't delete that text because the assumption is that you want a record of who deleted the attachment. If your code ccould do it, a user who is editing the document could do it, too.
You're probably going to have to remove it using back-end code going through PostClose events. There may be a temporary NotesItem holding that information that you can delete before that, perhaps in QuerySave. You'll have to go through the items in memory in order to figure that out.
Another option is dropping the 16 option from your flags parameter (7+64) and writing code to delete the attachments yourself.

How do I get Lotus Notes #MailSend to send an exact copy of my form?

For example, I am the buyer that wants to rate a seller.
I have this sample evaluation of a seller.
I need to send an email to the seller, Eden F. De Leon, an exact copy of the sample form.
However, all I can do is this code.
{`#MailSend
(Seller;
Buyer;
"";
"Rating for: " +Seller;
"";
"Sales evaluation for : " +Seller
+#NewLine+
"Buyer : " +Buyer
+#NewLine+
"Performance : " +Performance
+#NewLine
+#NewLine+
"Areas for Improvement:"
+#NewLine+
"1. " +Development1+ " - " +Rate1
+#NewLine+
"2. " +Development2+ " - " +Rate2
+#NewLine+
"3. " +Development3+ " - " +Rate3
+#NewLine
+#NewLine+
"Recommendation : " +Recommendation
`}
This will send an email notification like this.
What can I do to send an email notification which looks exactly the same as Sample Form. Thanks.
From the IBM documentation for #Mailsend
#MailSend (Formula Language)
There are two ways to use #MailSend:
When used with no parameters, #MailSend mails the current document (the one being processed when the #function is evaluated) to the recipient designated in the document's SendTo field.
The document must have a SendTo field.
When used with one or more parameters, #MailSend composes a new mail memo
etc., etc., etc....
You are using the second way, with parameters in the #MailSend call, so you are composing a new mail memo instead of mailing the current document.
You should either be using the first way, or you should be using LotusScript and the NotesDocument.send() method instead of a #Mailsend. Since your question is about #Mailsend, I'll continue my answer for that - but I'll come back to a final comment about using LotusScript at the end.
You will need to assign the recipient's address to the SendTo field before you call #MailSend. If your form doesn't have a SendTo field, add one. You can make it a hidden field. It will still work.
The user will be reading the email in his or her mail file, and your form is in your application's NSF file, so in order for the user to actually see the document that you emailed, you will also have to do one of two things:
Install a copy of your form in the mail template and apply that template to every recipient's mail file.
Or set the "Store form in document" property on your form.
There are pros and cons to each of these choices. Updating the template requires the cooperation of your server administrators, and it has to be done again after any upgrade to the Domino software. It's a pain, but ultimately it uses less storage and causes fewer problems for you as an app developer. Using 'Store form in document' doesn't impose any burden on your admins, but since both the emailed and the saved copy of the document will have the stored form this will use more storage space (not a lot, though). The bigger problem is that it will make it harder for you to maintain your app because any changes you make to the form in the future will not be reflected in documents that are already saved. (Sometimes this is a good thing, but usually it's not.) There's a way around that, though, by using an agent to delete the stored form from every document, which also recovers the extra space that has been used.
With LotusScript and the NotesDocument.Send() method, you have the ability to store the form in the email without storing it in the document that's saved in your app's NSF file. This is really the best approach in most cases.

Lotus Script - Send email does not attach form

I am trying to send email from Lotus Script. But the email doesn't seem to have the FORM ( named Email Form , referred below in the code ) attached to it, when received in the inbox.
When I check the Document property in the email, it says the form is "Memo" and the FROM, TO addresses are Blank.
I have defined the FROM, TO,SUBJECT,BODY fields in the Email Form in a specific format .
But all these field values are populated correctly in the form. Issue happens only after send .
The Same code works fine in some other Lotus Notes, when the email is triggered by another person, having a different Notes ID configured in that system .
Not sure if this is code issue, or Lotus Notes configuration issue .
Any help to solve this would be greatly appreciated . The for has the property " Store Form in Doc" set and even ComputeWithForm returns success .
Could this be a problem with my Lotus notes settings/configuration? .Same code sends email in correct format in some other system configured wit their Notes ID
Here is a sample code on the EMAIL Action button
Sub Click(Source As Button)
Set email = db.CreateDocument
Call email.ReplaceItemValue("Form", "Email Form")
Call email.ReplaceItemValue("Subject", " My TestEmail")
Call email.ReplaceItemValue("From", nom.Canonical)
Call email.ReplaceItemValue("SendTo", nom.Canonical)
Call email.ReplaceItemValue("Body", " Hello, my test email ")
Call email.Send(True,nom.Common)
End Sub
It seems you mixed syntax here, you both set SendTo and specify nom.common, only one should be done. As in the help you should use:
Dim session As New NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Set db = session.CurrentDatabase
Set doc = New NotesDocument( db )
doc.Form = "Email Form"
doc.SendTo = "Elissa Minty"
doc.Subject = "Here's the document you wanted"
Call doc.Send( true ) 'true here means you the form is stored and sent along with the document.
Now, check that you "Allow use of stored forms in this database." in your DB, could it be that this code exists in differents DBs and one doesn't have "Email Form" ? BTW check is it really "Email Form" and not "Email" ?
You may need also to check the local configuration on the client. To do this refer to Help.
Its not that complicated to send mails usually, with docs from a Mail Enabled database. But now you have added a more complicated solution, than necessary, you may want to review your solution, to save yourself of future problems.
You won't even need to LotusScript this, provided the Mail fields (SendTo as minimum) is there on the document.
See here how:
Designer 8.5.3 Help - Setting up automatic mailing

Difference in doc created by agent vs gui QuerySave fails to allow ODBC transfer

After I create a doc in a Notes app, I'm moving information from that doc to a postgres db.
The agent that transfers the data to postgres uses a field in the doc as the key field.
I'm running into the following problem:
- If I create the doc via the Notes client, the transfer occurs without problems.
- If I create the doc from an agent (which processes an incoming email and generates a valid key field value), the transfer fails with a null key error. If I then open and save the doc, the transfer is successful.
I key field value is not null, however. I can see it in the view, in the document, and in the document properties.
Any thoughts on how I might be able to figure this out would be appreciated.
thanks!
clem
============================
Thanks Torsten for the reply. I appreciate it. Well, there's not much to the code, really. Here's part of it. "x.LogNumber" returns a string. The format is something like T1234CP. I ended up adding the computeWithForm and setting the IsSummary tho I don't think it was necessary.
atdoc.logNumber = x.LogNumber
Call atdoc.computeWithForm(false, false)
Dim lnItem As NotesItem
Set lnItem = atDoc.getfirstitem("logNumber")
lnItem.IsSummary=True
Call atdoc.save(True, False)
=======================================
Once the doc is created, an agent runs that transfers some data from the doc to the postgres db via odbc:
'.. define the 'key field' to be use in the connection.select call
Dim selectFldLst As New LCFieldList
'.. add the key field name to the LCfieldList object.
Call selectFldLst.Append(NotesKeyFieldName, LCTYPE_TEXT)
'.. set this field to be the key field.
selectFldLst.Getfield(1).flags = LCFIELDF_KEY
Set Notes_LCFieldList = New LCFieldList ' flSrc
Set odbcDB_LCfieldList = New LCFieldList ' flDest
'.. get the key of the doc to transfer.
Set docWithTransferID = docsToTransferViewEntry.Document
selectFldLst.LogNumber = Trim(docWithTransferID.stid(0))
count = Notes_LCConnection.Select(selectFldLst, 1, Notes_LCFieldList)
^--- This selects the fields from the Notes document. This is where it fails. It returns 0 for 'count'. It should return 1. If I save the document manually, it works.
Sounds like your form is doing something to it. As a quick and dirty fix you could try doc.computeWithForm() in your agent before saving.
You create the records from Notes? Save yourself the trouble with code in the events and configure DECS. It creates the document for you reliably.
Most probably the items in the document you create do not have the "Summary" property set. That makes them "invisible" for some functions / subs...
Please provide some code about how you create the items. If you do it like Set item = New Item(doc, "Name", "Value") then the item will not be summary. Then you need to call a item.issummary = true
Taking into account the last comments I guess, that the agent sets the item with the wrong datatype. Again: The code of the agent would have helped to identify this.
If for example the Field in the document is of type text and the agent writes something like
docWithTransferID.stid = 1 then everything "seems" to be OK, as the field is shown correctly in the views and in the Form. But in the Properties of the document it will be shown as number. As soon as you save the document, the design of the form will force it to be a Text.
The same thing works vice versa. If the agent reads the data from a textfile (e.g) and does something like docWithTransferID.stid = "1", then the item will be text, no matter how it is defined in the Form. As soon as you save the document -> Voila, it will be a number again.
Background LotusScript does not know ANYTHING about the Form and therefor does not obey datatypes or formats... You have to take care for this yourself.

Compound js log user's actions

I need to find a way to log user's activities in my Compound.JS + MongoDB app.
It would be great to create a table and insert information like who (what login) updated/created/deleted which record in what table, what fields were changed from what to what?
I thought there might be a npm-package for this, but so far in google I find only about logging (writing to log-file) which is not what I want.
If you want to save it to a MongoDB collection, why not just create a model for it and save away?
LoggingModel.create({ user : req.session.user.id, action : "Created a new user." });
LoggingModel.create({ user : req.session.user.id, action: "Deleted user with id " + aId + "."});

Resources