gpt4 book ai didi

excel - 通过 MailEnvelope 发送电子邮件

转载 作者:行者123 更新时间:2023-12-04 20:35:24 24 4
gpt4 key购买 nike

我想将特定范围复制到邮件中(带图像)。

Sub Send_Range_Or_Whole_Worksheet_with_MailEnvelope()
'Working in Excel 2002-2016
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("EMAIL").Range("B2:W41")

'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 = ThisWorkbook.Sheets("EMAIL").Range("Z1").Value
.CC = ThisWorkbook.Sheets("EMAIL").Range("Z1").Value
.BCC = ""
.Subject = ThisWorkbook.Sheets("EMAIL").Range("D1").Value
.Display
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

为什么 MailEnvelope 显示一秒钟,之后什么也没有发生?

我替换了 .Send.Display但没有任何改变。或者,我尝试使用 RNGtoHTML 代码,但此代码不会复制图像(我在工作表“EMAIL”中有动态链接图片)。

最佳答案

试图通过它。

当您运行脚本时,它会在您到达这行代码时显示,

.display

但随后运行下面的代码,这将导致它停止显示。
ActiveWorkbook.EnvelopeVisible = False

如果您单步执行代码,您应该能够看到您的内容,直到您到达上面的代码行。

关于excel - 通过 MailEnvelope 发送电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43272849/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com