1
votes

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

2

2 Answers

1
votes

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.

1
votes

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