首页 文章

VBA-使用Lotus Notes在电子邮件上方插入电子邮件正文

提问于
浏览
1

我想要实现的是非常简单,在莲花笔记中将签名上方的电子邮件正文插入 . 运行时,我在vba中的代码会在主题,SendTo和Body字段中的Lotus notes粘贴中打开一个新的电子邮件窗口 . 一切都很完美,但是当插入身体时,它会将文字放在我的签名下面 . 我已经做了很多挖掘试图找到解决方案,但没有发现任何有效的方法 . 我发现的一些帖子建议删除签名,粘贴身体然后将签名重建到电子邮件中 - 这不是我想要的方法 .

这是我的代码:

Sub CreateEmail()

        Dim Notes As Object
        Dim Maildb As Object
        Dim objNotesDocument As Object
        Dim objNotesField As Object

        Set Notes = CreateObject("Notes.NotesSession")
        Set Maildb = Notes.GETDATABASE("", "")
        Maildb.OPENMAIL
        Set objNotesDocument = Maildb.CREATEDOCUMENT

        Subject = "Hey look at my email!!"
        Set objNotesField = objNotesDocument.APPENDITEMVALUE("Subject", Subject)
        Set objNotesField = objNotesDocument.APPENDITEMVALUE("SendTo", GetPrimaryEmail) 'calls a function to return the SendTo 
        Set objNotesField = objNotesDocument.APPENDITEMVALUE("Body", bodyInfo)  'calls a function to return the body contents. 

        Set workspace = CreateObject("Notes.NotesUIWorkspace")
        Call workspace.EDITDOCUMENT(True, objNotesDocument)

        AppActivate "Lotus Notes"

   End Sub

在此先感谢您的帮助!

1 回答

  • 4

    设置Body内容的另一种方法是在编辑模式下打开新文档(就像在代码末尾一样),然后将光标设置为Body字段并插入文本 . 您的代码可能如下所示:

    ...
        Set objNotesField = objNotesDocument.APPENDITEMVALUE("SendTo", GetPrimaryEmail) 'calls a function to return the SendTo 
    
        Set workspace = CreateObject("Notes.NotesUIWorkspace")
        Call workspace.EDITDOCUMENT(True, objNotesDocument)
        Set uidocument = workspace.CurrentDocument
        Call uidocument.GotoField("Body")
        Call uidocument.InsertText(bodyInfo)  'calls a function to return the body contents. 
    
        AppActivate "Lotus Notes"
    

相关问题