Excel VBA - 在Lotus notes电子邮件正文中插入空白行

时间:2014-09-02 15:31:13

标签: excel vba email excel-vba lotus-notes

我希望在莲花笔记电子邮件的正文中插入一个空白行。

例如: 目前我的身体显示:

"Hi this is the body of my email. <img></img>"

我希望我的电子邮件正文如下:

"Hi this is the body of my email.

<img></img>"

我该怎么做呢?有创意吗?

这是我的代码:

Sub CreateEmail()

    Dim Notes As Object
    Dim Maildb As Object
    Dim objNotesDocument As Object
    Dim objNotesField As Object
    Dim notesUIDoc As Object       
    Dim chartBody As Range

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

    Subject = "Hi read me!!"
    Set objNotesField = objNotesDocument.APPENDITEMVALUE("Subject", Subject)
    Set objNotesField = objNotesDocument.APPENDITEMVALUE("SendTo", GetPrimaryEmail)
    Set objNotesField = objNotesDocument.APPENDITEMVALUE("CopyTo", GetSecondaryEmail)

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

    'Copy and Paste diagram into email
    Set chartBody = Worksheets("Sheet1").Range("A1:G16")
    chartBody.Copy
    Call uidocument.GOTOFIELD("Body")
    Call uidocument.Paste 'Paste a diagram in the body of email. 
    'Paste in body text
    Call uidocument.GOTOFIELD("Body") 
    Call uidocument.INSERTTEXT(bodyInfo)'Calls a function to inserts the text for the body. 


    AppActivate "Lotus Notes"

End Sub

所有发生的事情是我插入图像然后将文本插入电子邮件正文中。问题是图片和文本粘贴在同一行上,这会导致奇怪的格式化。

1 个答案:

答案 0 :(得分:2)

在字符串中添加Chr(10)两次。然后在文本和图像之间出现空白

Call uidocument.INSERTTEXT(bodyInfo + Chr(10) + Chr(10))