我有一份工作表(" WC推荐通知")我需要将其放入电子邮件正文中,但不要立即发送,因为我需要浏览并将多个文档附加到电子邮件之前已发送。我发现宏将其发送到电子邮件正文中,但是一旦您点击它就会发送。我还发现了将工作簿附加为附件的宏。这些都不是我正在寻找的。
df2.plot(kind='bar')
答案 0 :(得分:0)
Sub Send_Range_Or_Whole_Worksheet_with_MailEnvelope()
Dim AWorksheet As Worksheet
Dim Sendrng As Range
Dim rng As Range
On Error GoTo StopMacro
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
'Fill in the Worksheet/range you want to mail
'Note: if you use one cell it will send the whole worksheet
Set Sendrng = Worksheets("WC Referral Notice").Range("A1:H101")
'Remember the activesheet
Set AWorksheet = ActiveSheet
With Sendrng
' Select the worksheet with the range you want to send
.Parent.Select
'Remember the ActiveCell on that worksheet
Set rng = ActiveCell
'Select the range you want to mail
.Select
' Create the mail and send it
ActiveWorkbook.EnvelopeVisible = True
With .Parent.MailEnvelope
' Set the optional introduction field thats adds
' some header text to the email body.
.Introduction = "This is test mail 2."
With .Item
.To = "adicker@generic.com"
.CC = ""
.BCC = ""
.Subject = "Blah Blah"
.Item.Send
End With
End With
'select the original ActiveCell
rng.Select
End With
'Activate the sheet that was active before you run the macro
AWorksheet.Select
StopMacro:
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
'ActiveWorkbook.EnvelopeVisible = False
End Sub