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

时间:2015-09-07 10:09:52

标签: java eclipse-rcp lotus-notes

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

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

如何打开"新邮件"从Lotus Notes Eclipse插件以编程方式编辑的消息?

由于

2 个答案:

答案 0 :(得分:1)

您需要将“新邮件”指定为mailto链接并执行链接。 另见:http://www.ibm.com/developerworks/lotus/library/notes8-data/

  

您可以通过操作系统的API而不是Lotus Notes API来完成此操作。具体而言,电子邮件操作使用mailto URL协议来创建新消息。   但是,这些链接的规范也允许传递其他几个数据。特别是,该操作使用指定消息正文的功能。您也可以取消收件人,因此您的链接看起来像mailto:?body=It+would+be+nice+to+email+from+here。   因为Lotus Notes实现了此协议,所以像这样的链接正确地创建了具有给定主体的新电子邮件。您所要做的就是启动链接。

答案 1 :(得分:1)

要使用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

End Sub