Using @dblookup with @mailsend

I’m piloting a system that sends multiple emails. Users are constantly wanting to make adjustments to the wording of emails and so I’d decided that rather than having to keep editing the template, I’d create a form (fEmail) and related view (fView) which administrators could use to edit email content.

The form contains text fields corresponding to each of the parameters of the @mailsend function plus a field (Email_Context) which contains a value to uniquely identify the record. Fields are populated with code exactly as if directly entered into the @mailsend function (e.g. the Email_Subject field contains: "Submitted Order No. " +FieldOrderNumber)

This is the code in my email button, which I was hoping to use in all my email buttons, and simply changing the value for the context:

context:=“form1.email1”;

EmailCopyTo:= @DbLookup(“”:“NoCache”;“”:“”;“vEmail”;context;“fEmail_CopyTo”);

EmailBlindCopyTo:= @DbLookup(“”:“NoCache”;“”:“”;“vEmail”;context;“fEmail_BlindCopyTo”);

EmailSubject:= @DbLookup(“”:“NoCache”;“”:“”;“vEmail”;context;“fEmail_Subject”);

EmailRemark:= @DbLookup(“”:“NoCache”;“”:“”;“vEmail”;context;“fEmail_Remark”);

EmailFields:= @DbLookup(“”:“NoCache”;“”:“”;“vEmail”;context;“fEmail_Fields”);

EmailFlags:= @DbLookup(“”:“NoCache”;“”:“”;“vEmail”;context;“fEmail_Flags”);

@MailSend(@UserName;EmailCopyTo;EmailBlindCopyTo;EmailSubject;EmailRemark;EmailFields;EmailFlags);

However, when sending emails I get “not found” error messages for the cc and bcc fields.

Another even bigger problem is that the resulting email Subject and Body contain the code returned from the @dblookup fields rather than the result of its evaluation, e.g. the Subject in the email contains:

"Submitted Order No. " +FieldOrderNumber 

rather than:

Submitted Order No. 1234

I’ve tried all sorts of things with @text but can’t solve the problem - any ideas what I’m doing wrong?

Subject: RE: Using @dblookup with @mailsend

Just because something looks like a formula, doesn’t mean that Notes will automatically treat it as a formula. You have to request that a string be evaluated as a formula by using @Eval (or in LotusScript using Evaluate).

As for your “not found” messages, I suspect the problem is the same. You’re not sending to the person whose name is listed in the CopyRecipients field in your document (for instance); instead you’re sending to the email address “CopyRecipients”.

Also, if there are multiple recipients, you need to make sure the source field is multivalued; if it’s just a string with commas (or some other separator) between the recipient addresses, that won’t work.

Subject: RE: Using @dblookup with @mailsend

Many thanks - your @eval suggestion has done the trick.

My @mailsend statement now reads:

@MailSend(@UserName;@Eval(EmailCopyTo);@Eval(EmailBlindCopyTo);@Eval(EmailSubject);@Eval(EmailRemark);@Eval(EmailFields);@Eval(EmailFlags));

The @eval function also fixed the problem with the cc and bcc fields.

Subject: @dblookup with @mailsend@eval for Notes 5?

I was so, so happy with the @eval functionality… but… I’m now told that migration to Notes 6 will postponed indefinately for a large number of my users.

As @eval is not available in Notes 5, is there another way of doing the same thing, which will work in Notes 5 as well as 6?