1

Currently developing a plug-in for Lotus Notes, and am having some issues understanding the Notes API.

I'd like to be able to click a button in my plugin's view, and trigger the opening of a New Mail message that is open for editing and has an already set attachment and text. I am able to do this via a shell command, but have yet to find the proper API call from within the Java Eclipse RCP plug-in.

How do I open a "New Mail" message for editing programatically from a Lotus Notes Eclipse plug-in?

Thanks

Richard Schwartz
  • 14,463
  • 2
  • 23
  • 41
Vlad Ilie
  • 1,389
  • 1
  • 13
  • 37

2 Answers2

1

You need to specify the "New Mail" as a mailto link and execute the link. See also: http://www.ibm.com/developerworks/lotus/library/notes8-data/

You can accomplish this action through the APIs of the operating system, rather than through Lotus Notes APIs. Specifically, the email action uses the mailto URL protocol to create the new message. The specification of these links, though, also allows for several other pieces of data to be passed. In particular, the action uses the ability to specify the body of the message. You can also leave off the recipient, so your link looks something like mailto:?body=It+would+be+nice+to+email+from+here. Because Lotus Notes implements this protocol, a link like this one correctly creates a new email with the given body. All you have to do is launch the link.

Niki van Stein
  • 10,564
  • 3
  • 29
  • 62
  • I would assume this is also dependent on the fact that Notes is the client that is configured to be the default mail client. Is it? – Vlad Ilie Sep 18 '15 at 12:30
  • Alright, well as far as I see, I could just call a process, like in this question http://stackoverflow.com/questions/5604698/java-programming-call-an-exe-from-java-and-passing-parameters but I don't really know how I could locate the notes.exe after deployment of the plugin... Do you maybe know a place in the Lotus API where one could find the folder of the notes install (and therefore the notes.exe)? – Vlad Ilie Sep 18 '15 at 12:53
  • I will also search for this in the meantime, thank you for your answer to my question and to my comments :) – Vlad Ilie Sep 18 '15 at 12:54
  • normally in C:\Program Files\IBM\Notes or in C:\Program Files (x86)\IBM\Notes, see also http://www-10.lotus.com/ldd/dominowiki.nsf/dx/Various_ways_to_launch_Notes_client but not sure how to do it in the API. – Niki van Stein Sep 18 '15 at 12:56
1

To create an email message using the Notes APIs, you would code something like the following. This is working code which creates an editable email message by clicking on a button. This code will present a message box to the user asking for the text which they want to add to the message. The user has the option to cancel the email prior to sending.

Sub Click(Source As Button)
Dim session As New NotesSession
Dim workspace As New NotesUIWorkspace
Dim db As NotesDatabase
Dim uidoc As NotesUIDocument
Dim doc As NotesDocument, doc2 As NotesDocument
Dim itemRT As NotesRichTextItem
Dim item As NotesItem
Dim strComments As String
Dim strBody As String
Dim strSubject As String
Dim varSubject As Variant
Dim strInputText As String
Const NEW_LINE            = |

|

'This section is used to select who will receive responses, enter the number of people who will receive responses next to SendTo, and then below specify the people starting with (0) -----
'--------------------------------------------------------------------------------------
Dim SendTo(2) As String
SendTo(0) = "Notes ID of email recipient"
'--------------------------------------------------------------------------------------

'This section determines what the subject tag line will be for the feedback note.  Enter what you would like next to SubjTemp
'--------------------------------------------------------------------------------------
Dim SubjTemp As String
SubjTemp = "Feedback -- " 
'--------------------------------------------------------------------------------------


Set uidoc = workspace.CurrentDocument
Set doc = uidoc.Document
Set db = session.CurrentDatabase
Set itemRT=doc.getFirstItem("body")   ' get rid of attachments from background document
If doc.HasEmbedded = True Then   ' see if background document has any attachments
    Forall x In itemRT.EmbeddedObjects
        If x.type=1454 Then
            x.remove
        End If
    End Forall
End If
Set doc2 = doc.CreateReplyMessage( False )
Set item = doc.GetFirstItem("Subject")
varSubject = item.Values
strSubject = SubjTemp & varSubject(0) 
Set item = doc2.ReplaceItemValue("Subject", strSubject)
strInputText = "Thank you for providing us with your valuable feedback!" & NEW_LINE & "Please enter your comments in the space below." & NEW_LINE & "If you do not want to send a feedback, click on Cancel."
strComments = Inputbox$(strInputText, "Comments")
If strComments = "" Then
    Msgbox "You did not enter any comments, a feedback message will not be sent."
Else
    strBody = "Very Useful" & NEW_LINE & NEW_LINE & "Comments:  " & strComments
    Set item = doc2.ReplaceItemValue("Rating",  "Very Useful")
    Set item = doc2.ReplaceItemValue("Comments", strComments)
    Call doc2.Removeitem("Body")     ' get rid of original body field
    Set item = doc2.ReplaceItemValue("Body", strBody)
    doc2.SendTo = SendTo
    Call doc2.Send(False)
    Messagebox "Thank you for your feedback, a message has been sent.", MB_OK, "Message Sent"
End If

End Sub

Bob Dill
  • 1,000
  • 5
  • 13
  • Thank you for your answer. As far as I can see, this is LotusScript. How would I integrate this into a Java Eclipse RCP plug-in? – Vlad Ilie Sep 18 '15 at 12:29
  • The notes clients currently in production is based on eclipse. I understood your question to be one of how to use the Notes API from within Notes (e.g. which puts this within eclipse). Are you trying to programatically drive this from an external app? If so, would probably need to use the Notes C/C++ api. – Bob Dill Sep 18 '15 at 15:24
  • If it's Eclipse based shouldn't it be a Java API? And yes this is what I am trying to do and the API is not the best commented one... – Vlad Ilie Sep 18 '15 at 15:26