大家好,我是 VBA 编程的新手,已经学习了一周。我正在尝试学习编写自己的代码,但我遇到了一个问题。
我的最终结果是,我向所有供应商发送了一封电子邮件,并在密件抄送字段中注明了他们的姓名。我当前的代码为每个不需要的联系人创建了一封电子邮件。我确信这是一个简单的修复,但这是我到目前为止的代码。我感谢您的帮助!
Private Sub Compose_Button_Click()
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.mailItem
Dim objOultlookRecip As Outlook.Recipients
Dim objOutlookAttach As Outlook.Attachments
Dim TheAddress As String
Set db = CurrentDb
Set rst = Me.Recordset
rst.MoveFirst
Set objOutlook = CreateObject("Outlook.Application")
Do Until rst.EOF
'Create Email message
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
TheAddress = rst![E-Mail]
With objOutlookMsg
Set objOutlookRecip = .Recipients.Add(TheAddress)
objOutlookRecip.Type = olBCC
objOutlookMsg.Display
End With
rst.MoveNext
Loop
Set objOutlookMsg = Nothing
Set objOutlook = Nothing
End Sub
谢谢!!