MS Access-记录集-遍历表并发送电子邮件-获取“运行时错误440:数组索引超出范围

问题描述

我有一个表单,其中包含我希望我的代码循环通过并发送个人电子邮件的人员列表。我之前已经做过,但是以某种方式我却忽略了某些事情。我在表单中使用的主要变量是NAME(我正在发送电子邮件的人的姓名)和EMAIL(电子邮件地址)。不知道为什么我会得到“数组索引越界”错误,但是希望这是一个简单的解决方法。任何帮助表示赞赏!


Set OutApp = CreateObject("Outlook.Application")

Dim rs As DAO.Recordset

Set rs = CurrentDb.OpenRecordset("My_Table")

With rs

    If .EOF And .BOF Then

        MsgBox "No emails will be sent becuase there are no records assigned from the list",vbInformation

    Else

        Do Until .EOF

            stremail = Me![Email] 'This is the list of people's email addresses I want to email

            strsubject = "the subject - placeholder for now"

            strbody = "Dear " & Me![Name] & "Hello and goodbye."

 

            Set OutMail = OutApp.CreateItem(olMailItem)

            With OutMail

                .To = stremail

                .CC = ""

                .BCC = ""

                .Subject = strsubject

                .Body = strbody

 

                .SendUsingAccount = OutApp.Session.Accounts.Item(2)

                .Send

            End With

            .MoveNext

        Loop

    End If

End With

End Sub

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...