这是我在我的一个数据库中使用的电子邮件代码。我只是为要发送给的人、抄送、主题和正文设置了变量。然后您只需使用 DoCmd.SendObject 命令。我还在正文之后将其设置为“True”,以便您可以在消息自动发送之前对其进行编辑。
Public Function SendEmail2()
Dim varName As Variant
Dim varCC As Variant
Dim varSubject As Variant
Dim varBody As Variant
varName = "james@yahoo.com"
varCC = "billy@gmail.com, joe@yahoo.com"
'separate each email by a ','
varSubject = "Hello"
'Email subject
varBody = "Let's get ice cream this week"
'Body of the email
DoCmd.SendObject , , , varName, varCC, , varSubject, varBody, True, False
'Send email command. The True after "varBody" allows user to edit email before sending.
'The False at the end will not send it as a Template File
End Function