Excel VBA发送电子邮件

我想要一个macros在Outlook中发送excel文档作为电子邮件的正文。 我试图录制一个macros,并发送它,但没有写任何代码。 我将创build一个batch file,在预定时间打开excel,我希望我在excel中运行的程序能够发送标签“Assembly”,“Lam”,“Finish”和“MW”作为邮件正文在outlook。 这甚至有可能吗?

快速谷歌search将走了很长的路要走。

请参阅: 如何在Excel中使用Visual Basic for Applications发送电子邮件中的一系列单元格

这是相关的VBA代码。

Sub Send_Range() ' Select the range of cells on the active worksheet. ActiveSheet.Range("A1:B5").Select ' Show the envelope on the ActiveWorkbook. ActiveWorkbook.EnvelopeVisible = True ' Set the optional introduction field thats adds ' some header text to the email body. It also sets ' the To and Subject lines. Finally the message ' is sent. With ActiveSheet.MailEnvelope .Introduction = "This is a sample worksheet." .Item.To = "E-Mail_Address_Here" .Item.Subject = "My subject" .Item.Send End With End Sub 

对于你的具体情况,你将不得不修改上面的代码,以便为循环中的4个工作表中的每一个select所有的单元格 – "Assembly" "Lam" "Finish""MV" ,并将其粘贴到电子邮件正文中。