首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >VBA到Lotus如何添加附件

VBA到Lotus如何添加附件
EN

Stack Overflow用户
提问于 2015-01-23 03:54:36
回答 1查看 2.1K关注 0票数 0

目前,我正在使用下面的代码进行一些修改,以创建我的消息,但是要增加它的附件功能是很困难的,有人能帮我做一下这个吗?

代码语言:javascript
运行
复制
Sub Notes_Email_Excel_Cells()
Dim NSession As Object
Dim NDatabase As Object
Dim NUIWorkSpace As Object
Dim NDoc As Object
Dim NUIdoc As Object

Set NSession = CreateObject("Notes.NotesSession")
Set NUIWorkSpace = CreateObject("Notes.NotesUIWorkspace")
Set NDatabase = NSession.GetDatabase("", "")

If Not NDatabase.IsOpen Then
    NDatabase.OPENMAIL
End If

'Create a new document

Set NDoc = NDatabase.CreateDocument

With NDoc
    .SendTo = "email.address@email.com"
    .CopyTo = ""
    .subject = "Pasted Excel cells " & Now

    'Email body text, including marker text which will be replaced by the Excel cells

    .body = "Text in email body" & vbNewLine & vbNewLine & _
        "**PASTE EXCEL CELLS HERE**" & vbNewLine & vbNewLine & _
        "Excel cells are shown above"

    .Save True, False
End With

'Edit the just-created document to copy and paste the Excel cells into it

Set NUIdoc = NUIWorkSpace.EDITDocument(True, NDoc)

With NUIdoc

    'Find the marker text in the Body item

    .GotoField ("Body")
    .FINDSTRING "data"

    'Replace it with the Excel cells

    Sheets("Sheet1").Range("A1:E6").Copy
    .Paste
    Application.CutCopyMode = False

    '.Send
    '.Close
End With

Set NSession = Nothing
End Sub

我相信我可能会成功地添加以下几行代码,但我仍然需要在工作中测试它,因为我是在我的电脑上发布的:

代码语言:javascript
运行
复制
Dim notesRichTextItem As NotesRichTextItem
'[...]
Set notesRichTextItem = doc.CreateRichTextItem("Body")
'[...]
Call notesRichTextItem.EmbedObject(EMBED_ATTACHMENT, "", "File path")

我还没有真正理解EmbedObject参数,因为我在IBM上发现的内容没有消除我的所有疑虑( 这里 ),如下所示

定义在中的 NotesRichTextItem 语法 设置notesEmbeddedObject = notesRichTextItem.EmbedObject(类型%、类$、源$、名称$)

所以应该是

代码语言:javascript
运行
复制
notesEmbeddedObject = notesRichTextItem.EmbedObject(1454,"",**FILEPATH**,"")

而不是我以前的

代码语言:javascript
运行
复制
    Call notesRichTextItem.EmbedObject(EMBED_ATTACHMENT, "", "File path")

,但是我将如何将它添加到消息的末尾?甚至,我如何在代码中调用它呢?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-01-23 04:05:23

您应该将Body字段的初始化转换为NotesRichTextItem初始化。

而不是:

代码语言:javascript
运行
复制
.body = "Text in email body" & vbNewLine & vbNewLine & _
    "**PASTE EXCEL CELLS HERE**" & vbNewLine & vbNewLine & _
    "Excel cells are shown above"

写这个:

代码语言:javascript
运行
复制
Set notesRichTextItem = .CreateRichTextItem("Body")
notesRichTextItem.AppendText("Text in email body")
notesRichTextItem.AddNewline(2)
notesRichTextItem.AppendText("**PASTE EXCEL CELLS HERE**")
notesRichTextItem.AddNewline(2)
notesRichTextItem.AppendText("Excel cells are shown above")
notesRichTextItem.AddNewline(1)
'And here comes the attachment:
Call notesRichTextItem.EmbedObject(EMBED_ATTACHMENT, "", "File path")
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/28102764

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档