从 Access 2010 VBA 中的记录集创建邮件列表?

发布于 2024-12-03 08:16:21 字数 513 浏览 6 评论 0原文

我正在尝试从表中提取电子邮件地址并将其格式化为可在 Outlook 邮件的“收件人:”字段中使用的字符串。由于某种原因,我编写的循环冻结了程序。谁能发现我做错了什么或提供更好的方法来做到这一点?这是我现在的代码:

Private Function GetMailingList() As String

    Dim db As DAO.Database
    Dim rs As DAO.Recordset
    Dim results As String

    results = ""
    Set db = CurrentDb
    Set rs = db.OpenRecordset("lut_holdEmailList")

        Do Until rs.EOF
            results = results & rs.Fields("emailAddress") & ", "

        Loop

    GetMailingList = results

End Function

I'm trying to pull email addresses from a table and format them into a string that can be used in the "TO:" field of an outlook message. For some reason, the loop that i wrote is freezing the program. Can anyone spot what I'm doing wrong or offer a better way to do this? here is the code i have at the moment:

Private Function GetMailingList() As String

    Dim db As DAO.Database
    Dim rs As DAO.Recordset
    Dim results As String

    results = ""
    Set db = CurrentDb
    Set rs = db.OpenRecordset("lut_holdEmailList")

        Do Until rs.EOF
            results = results & rs.Fields("emailAddress") & ", "

        Loop

    GetMailingList = results

End Function

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

客…行舟 2024-12-10 08:16:21

您错过了 MoveNext 调用:

将此行添加到 Do Untill 循环中

rs.MoveNext()

You missed the MoveNext call:

add this line to the Do Untill Loop

rs.MoveNext()
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文