简体   繁体   English

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

[英]VBA-Insert body of email above signature using Lotus Notes

What I am trying to achieve is very simple, insert the body of an email above the signature in lotus notes. 我要达到的目的非常简单,将一封电子邮件正文插入莲花笔记中的签名上方。 The code I have in vba, when run, opens a new email window in lotus notes pastes in the Subject, SendTo and Body fields. 运行时,我在vba中拥有的代码会在Lotus Notes粘贴中的“主题”,“发送至”和“正文”字段中打开一个新的电子邮件窗口。 Everything works perfectly, but when the body is inserted it puts the text below my signature. 一切正常,但插入主体后,它将文字置于我的签名下方。 I've done a ton of digging to try and find a solution, but haven't found anything that has worked just right. 我已经进行了大量的挖掘工作以尝试找到解决方案,但是还没有发现任何可以正常工作的方法。 A few posts I've found suggest removing the signature, pasting the body and then rebuilding the signature into the email--not really the approach i'd like. 我发现的一些帖子建议删除签名,粘贴正文,然后将签名重新构建到电子邮件中,这并不是我想要的方法。

Here is my code: 这是我的代码:

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

Thanks in advance for any help! 在此先感谢您的帮助!

A different approach to set the Body content is to open the new document in edit mode (like you do at the end of your code) and then set cursor to Body field and insert the text. 设置“正文”内容的另一种方法是在编辑模式下打开新文档(就像在代码末尾一样),然后将光标设置到“正文”字段并插入文本。 Your code could look like this: 您的代码可能如下所示:

    ...
    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"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM