如何以编程方式创建新邮件消息以在 Lotus Notes 中进行编辑?

How to programatically create a new mail message for editing in lotus notes?

目前正在为 Lotus Notes 开发插件,但在理解 Notes API 时遇到了一些问题。

我希望能够在我的插件视图中单击一个按钮,并触发打开新邮件消息,该消息已打开以供编辑,并且已经设置了附件和文本。我可以通过 shell 命令执行此操作,但尚未从 Java Eclipse RCP 插件中找到正确的 API 调用。

如何从 Lotus Notes Eclipse 插件程序打开 "New Mail" 消息进行编辑?

谢谢

您需要将 "New Mail" 指定为 mailto link 并执行 link。 另见: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.

要使用 Notes API 创建电子邮件消息,您需要编写如下代码。这是通过单击按钮创建可编辑电子邮件消息的工作代码。此代码将向用户显示一个消息框,询问他们要添加到消息中的文本。用户可以选择在发送之前取消电子邮件。

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

结束子