vba - MS Access - 记录集 - 循环遍历表并发送电子邮件 - 得到“运行时错误 440:数组索引超出范围
问题描述
我有一个表单,其中包含我希望我的代码循环并发送个人电子邮件的人员列表。我以前做过,但不知何故我忽略了一些东西。我在表单中使用的主要变量是 NAME(我正在发送电子邮件的人的姓名)和 EMAIL(电子邮件地址)。不知道为什么我得到 Array Index Out of Bounds 错误,但希望这是一个简单的修复。任何帮助表示赞赏!
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
解决方案
推荐阅读
- python - 如何在 Python 中获取 PyPDF2 的命令
- ruby-on-rails - 提供参数时忽略 Rails 'remote:true'
- javascript - Web Audio API:我如何检测语音并录制直到静音,有或没有一键通按钮
- tensorflow - 我可以将 VGG16 用于一个通道图像吗?
- jquery - 使用 Laravel Passport 使用 REST API 获取访问令牌时如何在客户端保留
- javascript - 带有 JavaScript 和 HTML 的 JSON
- css - 到页面末尾但不激活滚动的 CSS 块
- arrays - Angular中带有array.push()的无限循环
- google-bigquery - BigQuery 中的拒绝/不良记录表
- c++ - 构建时如何解决 ReLU is not a member of torch::nn 错误?