我很难让.To = emails
识别此代码中的多个电子邮件地址。
我正在尝试使用SELECT
函数来获取电子邮件地址列表WHERE Active
(是/否复选框)。然后尝试将此列表插入.To = <list of multiple email addresses>
。我想避免在这个自动电子邮件中使用Outlook,并获取一个电子邮件地址列表,它将被发送到存储在表中以便于管理,这样就不需要进入代码来调整地址。我是以错误的方式来做这件事的吗?
<code above here>
Dim dbs As Database, emails As Recordset
Set dbs = CurrentDb
Set emails = dbs.OpenRecordset "SELECT EmailAddy FROM EmailTbl WHERE Active = -1;")
emails.MoveLast
With iMsg
.Configuration = iCfg
.To = emails
.CC = ""
<code below here>
答案 0 :(得分:1)
属性iMsg.To
可能接受分隔的电子邮件地址字符串,就像DoCmd.SendObject()
命令一样。下面是一个如何将这样一个字符串组合在一起的例子。
' Update this constant to a comma, pipe, etc. as needed
Const EMAIL_DELIMITER As String = ";"
' Stores the delimited list of emails
Dim emailList As String
With CurrentDb
With .OpenRecordset "SELECT EmailAddy FROM EmailTbl WHERE Active = -1;")
Do While Not .EOF
' This IsNull check is not necessary if EmailAddy is never null
If Not IsNull(!EmailAddy) Then
emailList = emailList & !EmailAddy & EMAIL_DELIMITER
End If
.MoveNext
Loop
.Close
End With
End With
' Lob off the trailing delimiter
If Len(emailList) Then emailList = Left(emailList, Len(emailList) - Len(EMAIL_DELIMITER))