首页 文章

Excel VBA发送电子邮件[关闭]

提问于
浏览
0

我想要一个宏来发送excel doc作为outlook中的电子邮件正文 . 我尝试录制宏并发送它,但是没有写任何代码 . 我将创建一个批处理文件,它将在预定的时间打开excel,我希望我在excel中运行的程序然后运行标签“Assembly”“Lam”“Finish”和“MW”作为电子邮件的正文在展望中 . 这甚至可能吗?

1 回答

  • 3

    quick google搜索会有很长的路要走 .

    见:How to send a range of cells in an e-mail message by using Visual Basic for Applications in Excel

    这是相关的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个工作表中的每一个的所有单元格 - 循环中的 "Assembly" "Lam" "Finish""MV" 并将其粘贴到电子邮件正文中 .

相关问题