通过marco向多个收件人发送带有Excel工作表的电子邮件,可以按照以下步骤进行操作:
Sub SendEmail()
Dim OutlookApp As Object
Dim OutlookMail As Object
Dim Recipients As String
Dim Subject As String
Dim Body As String
Dim AttachmentPath As String
' 设置收件人列表
Recipients = "recipient1@example.com; recipient2@example.com"
' 设置邮件主题
Subject = "这是邮件主题"
' 设置邮件正文
Body = "这是邮件正文"
' 设置附件路径
AttachmentPath = "C:\path\to\your\file.xlsx"
' 创建Outlook应用对象
Set OutlookApp = CreateObject("Outlook.Application")
' 创建邮件对象
Set OutlookMail = OutlookApp.CreateItem(0)
' 设置收件人
OutlookMail.To = Recipients
' 设置邮件主题
OutlookMail.Subject = Subject
' 设置邮件正文
OutlookMail.Body = Body
' 添加附件
OutlookMail.Attachments.Add AttachmentPath
' 发送邮件
OutlookMail.Send
' 释放对象
Set OutlookMail = Nothing
Set OutlookApp = Nothing
End Sub
请注意,以上代码是使用Microsoft Outlook作为邮件客户端的示例,如果你使用其他邮件客户端,需要相应地修改代码以适配该客户端。
推荐的腾讯云相关产品:腾讯企业邮件(https://cloud.tencent.com/product/exmail)
领取专属 10元无门槛券
手把手带您无忧上云