Reputation: 2169
I'm trying to pass a field value from a application to my own mail database opened in browser.
I got the entire url ( my first reaction: wow, so long )
https://server/MyName.nsf/($Inbox)/$new/?EditDocument&Form=h_PageUI&PresetFields=h_EditAction;h_New,s_NotesForm;Memo,s_ParentContentId;($Inbox)1,s_ViewName;(%24Inbox),s_InheritAttachment;false,s_SortOrder;1,s_SortColumnPN;$70&ui=portal
How can I refer easily to the recipient field ? ( To:
field ) from the mail database ?
I want to use a sessionScope which picks the desired value and then pass it to the above field.
I did for the above requirement in a lotus notes application using lotusScript something like this:
Sub Click(Source As Button)
// soome declarations
Set db=s.CurrentDatabase
Dim dcc As NotesDocumentCollection
Set dcc = db.UnprocessedDocuments
Dim item As NotesItem
Set doc = dcc.GetFirstDocument
' em$=doc.nms_Email(0)
While Not (doc Is Nothing)
If doc.HasItem ("nms_Email") Then
Set item=doc.GetFirstItem("nms_Email")
Else
If doc.HasItem ("txt_Email") Then
Set item=doc.GetFirstItem("txt_Email")
Else
Messagebox "No value for the field!"
Exit Sub
End If
End If
Forall e In item.values
If Len(e) > 2 Then em$=em$+e+"; "
End Forall
Set doc=dcc.GetNextDocument(doc)
Wend
If em$=";" Then Exit Sub
test$=Strleftback(em$, ";")
var=Evaluate({@Explode("} & test$ & {"; ";")})
var2=Evaluate("@MailDbName")
mdb$=var2(1)
msv$ =var2(0)
Set dbm=s.GetDatabase(msv$, mdb$, False)
Set docW = dbm.CreateDocument
docW.form = "Memo"
docW.SendTo=var
Set uidoc = w.EditDocument(True,docW)
End Sub
But how can I do the same thing in xpages?
Upvotes: 2
Views: 367
Reputation: 3365
If I understood correctly, you want to generate a URL that composes a new E-mail on the iNotes even it has not been configured as the default E-mail client.
Short way to that, with a hacky method, adding SendTo
to the PresetFields
parameter in the URL.
Here is the URL you have provided:
https://server/MyName.nsf/($Inbox)/$new/?EditDocument&Form=h_PageUI&PresetFields=h_EditAction;h_New,s_NotesForm;Memo,s_ParentContentId;($Inbox)1,s_ViewName;(%24Inbox),s_InheritAttachment;false,s_SortOrder;1,s_SortColumnPN;$70&ui=portal
Will be modified as:
...&PresetFields=...othervalues...,SendTo;someEmailAddress&ui=portal
Instead of usual query strings, iNotes will get Name1;Value1,Name1;Value1
format for this parameter. So,
SendTo;[email protected]
for single e-mail address.
SendTo;[email protected]%[email protected]
for multiple (%2c is for comma. Usual comma is to separate name-value sets).
SendTo;[email protected],CopyTo;[email protected],Subject;Test,Body;Test
with other options.
Of course, query string is a limiting factor. You can't have too many values.
The alternative has been explained by Stephan: To create a document in the mail database and use:
https://server/mail/myname.nsf/0/unid?EditDocument
Mail database will default to iNotes in such case. However, in this scenario, you should save the document into the mail database.
Upvotes: 1
Reputation: 3524
My solution is based on mailto:
protocol. According to wikipedia you can use it with coma separated list of addresses.
To handle mailto:
urls by iNotes you need to go to iNotes preferences, or to use this little hack: https://www.bleedyellow.com/blogs/tomsparrow/entry/inotes-mailto.
All you need to do in your XPages code is a correct mailto:
link and let user to click it.
Upvotes: 0
Reputation: 20404
Paul's answer is one approach. The other would be to do the same as you did in the LotusScript. Create a document in the mail file, save it (as Draft) and then use the URL to open it. You can figure out the needed URL using the developer tools opening a manually created draft
Upvotes: 0
Reputation: 15739
iNotes is not an XPages application (which is why the URL is so long).
You can create a new email with the relevant value in the "to" field using a mailto:
link. This is standard web development functionality, not proprietary to XPages or Domino, so there are plenty of pages explaining the functionality. That functionality creates a new mail using whatever is the default mail program for the user's computer. I'm not sure how that works with iNotes though.
Alternatively, iNotes documentation may tell you what you need to add into the URL to set the "to" field.
Upvotes: 1