0

我正在尝试向日历事件的联系人组发送电子邮件通知。

为此,我使用了类别,例如Send Message将向指定联系人组发送电子邮件的类别。

我的VB代码如下:

Private Sub Application_Reminder(ByVal Item As Object)
Dim objMsg As MailItem

Set objMsg = Application.CreateItem(olMailItem)

Select Case Item.Categories
 Case "Send Message"

 Set objGroup = GetObject _
("LDAP://cn=Scientists,ou=R&D,dc=NA,dc=fabrikam,dc=com")

objGroup.GetInfo

arrMemberOf = objGroup.GetEx("Test")

For Each strMember In arrMemberOf
    Set objUser = GetObject("LDAP://" & strMember)
    strEmail = Replace(objUser.mail, "@", "@internal.")
    emailList = emailList & strEmail & ";"
Next

strTo = emailList

 objMsg.To = strTo
 objMsg.Subject = "BI Test"
    objMsg.Body = "This is a test"

我不太确定如何设置 LDAP 参数,我是新手。

提前致谢。

4

1 回答 1

0

我想通了,见下图:

Private Sub Application_Reminder(ByVal Item As Object)
Dim objMsg As MailItem
Dim Conn
Dim cmd
Dim ToStrn

Set objMsg = Application.CreateItem(olMailItem)
Set Conn = CreateObject("ADODB.Connection")
Conn.ConnectionString = "driver={SQL Server}; server=localhost;user id = sa; password=mypass; Initial Catalog=TestDatabase"
Conn.Open

Select Case Item.Categories
 Case "Send Message"

 Set Rs = CreateObject("ADODB.recordset")
 Rs.Open "Select * from Cleints where Rank = 'MNGR'", Conn
 While Not Rs.EOF
    ToStrn = ToStrn + CStr(Rs.Fields.Item("Email")) + "; "
    Rs.MoveNext
 Wend

 objMsg.To = ToStrn
 objMsg.Subject = "SQL Test"
 objMsg.Body = "This is a test message sent via a calender event."
于 2013-08-29T12:30:06.537 回答