Excel 使用VBA和IBM Lotus Notes发送电子邮件

Excel 使用VBA和IBM Lotus Notes发送电子邮件,excel,vba,lotus-notes,Excel,Vba,Lotus Notes,我知道关于类似问题的话题,但没有一个能直接解决我的问题(或者至少我看不到)。我正在使用以下代码: Sub SendEmailUsingCOM() '******************************************************************************************* ' Unlike OLE automation, one can use Early Binding while using COM ' To do so, repl

我知道关于类似问题的话题,但没有一个能直接解决我的问题(或者至少我看不到)。我正在使用以下代码:

Sub SendEmailUsingCOM()

'*******************************************************************************************
' Unlike OLE automation, one can use Early Binding while using COM
' To do so, replace the generic "object" by "commented" UDT
' Set reference to: Lotus Domino Objects
'*******************************************************************************************
Dim nSess       As Object 'NotesSession
Dim nDir        As Object 'NotesDbDirectory
Dim nDb         As Object 'NotesDatabase
Dim nDoc        As Object 'NotesDocument
Dim nAtt        As Object 'NotesRichTextItem
Dim vToList     As Variant, vCCList As Variant, vBody As Variant
Dim vbAtt       As VbMsgBoxResult
Dim sFilPath    As String
Dim sPwd        As String

'*******************************************************************************************
'To create notesession using COM objects, you can do so by using.
'either ProgID  = Lotus.NotesSession
'or     ClsID   = {29131539-2EED-1069-BF5D-00DD011186B7}
'Replace ProgID by the commented string below.
'*******************************************************************************************
Set nSess = CreateObject("Lotus.NotesSession") 'New:{29131539-2EED-1069-BF5D-00DD011186B7}

'*******************************************************************************************
'This part initializes the session and creates a new mail document
'*******************************************************************************************
sPwd = Application.InputBox("Type your Lotus Notes password!", Type:=2)
Call nSess.Initialize(sPwd)
Set nDir = nSess.GetDbDirectory("")
Set nDb = nDir.OpenMailDatabase
Set nDoc = nDb.CreateDocument

'*******************************************************************************************
'If you want to send it to multiple recipients then use variant array to get the names from
'the specified range as below
'Add / Remove Comment mark from vCCList as per your needs.
'*******************************************************************************************
vToList = Application.Transpose(Range("A1").Resize(Range("A" & Rows.Count).End(xlUp).Row).Value)
vCCList = Application.Transpose(Range("B1").Resize(Range("B" & Rows.Count).End(xlUp).Row).Value)

'*******************************************************************************************
'If you want to send it to multiple recipients then use variant array to get the names from
'the specified range as below
'Add / Remove Comment mark from vCCList as per your needs.
'*******************************************************************************************
With nDoc

    Set nAtt = .CreateRichTextItem("Body")
    Call .ReplaceItemValue("Form", "Memo")
    Call .ReplaceItemValue("Subject", "Test Lotus Notes Email using COM")

    With nAtt
        .AppendText (Range("C2").Value)

       'Decide if you want to attach a file.
        vbAtt = MsgBox("Do you want to attach document?", vbYesNo, "Attach Document")

            Select Case vbAtt
            Case 6
                .AddNewLine
                .AppendText ("********************************************************************")
                .AddNewLine
                sFilPath = Application.GetOpenFilename
                Call .EmbedObject(1454, "", sFilPath) '1454 = Constant for EMBED_ATTACHMENT
            Case 7
                'Do Nothing
            End Select

    End With

    Call .ReplaceItemValue("CopyTo", vCCList)
    Call .ReplaceItemValue("PostedDate", Now())
    Call .Send(False, vToList)

End With

End Sub
代码停在Set nSess=CreateObject(“Lotus.NotesSession”)处,表示运行时错误429:ActiveX组件无法创建对象

我看到一些关于缺少nnotes.dll的讨论,但当我尝试使用工具>引用>添加它并浏览到nnotes.dll文件时,它会说“无法添加对指定文件的引用” 当然,我错过了一些基本知识,但我只想让它工作,并通过电子邮件发送excel中的特定范围。
您知道,理想情况下,一步一步地,我应该做什么吗?

当将Set nSess=CreateObject(“Lotus.NotesSession”)更改为Set nSess=CreateObject(“Notes.notession”)时,我可能会更进一步,但键入密码后,我在调用nSess.Initialize(sPwd)时遇到了一个调试消息“Object不支持此属性或方法”。您不能仅添加nnotes.dll作为引用。必须注册这些类。Notes.NotesSessoin是一个OLE类,它不支持该方法。LotusNotesSession是一个COM类,它确实支持该方法。OLE类要求Notes客户端正在运行。如果它不运行,它将启动它。客户端本身必须请求密码。COM类只需要安装和配置Notes客户机(或Domino服务器)。它不必运行。如何执行VBA?哪个Microsoft应用程序?哪个版本,是32位还是64位。