我正在处理我想要自动化的Excel报告,但是,单元格的范围未粘贴在Outlook中.
这是我的代码:
Sub Mail_Selection_Range_Outlook_Body()
Dim rng As Range
Dim OutApp As Object
Dim OutMail As Object
Set rng = Nothing
On Error Resume Next
' Only send the visible cells in the selection.
Set rng = Selection.SpecialCells(xlCellTypeVisible)
Set rng = Sheets("Sheet1").RangeToHtml("D4:D12").SpecialCells(xlCellTypeVisible, xlTextValues)
On Error GoTo 0
If rng Is Nothing Then
MsgBox "The selection is not a range or the sheet is protected. " & _
vbNewLine & "Please correct and try again.", vbOKOnly
Exit Sub
End If
With Application …Run Code Online (Sandbox Code Playgroud) 我有一个数据列表,比如存储在Excel工作表中的客户信息(名称,电子邮件,金额等).我的目标是单击Excel中的按钮,并将每个客户端的信息发送到Outlook模板中.
例如.亲爱的<<客户名>> =亲爱的约翰史密斯
我的代码到目前为止:
Dim myOlApp As Outlook.Application
Dim MyItem As Outlook.MailItem
Set myOlApp = CreateObject("Outlook.Application")
Set MyItem = myOlApp.CreateItemFromTemplate("C:\egTemplate.oft")
With MyItem
.To = Worksheets("Clients").Range(1, 2)
.Subject = "Monthly bill"
'Refer to and fill in variable items in template
.Save
End With
Set MyItem = Nothing
Set MyOlApp = Nothing
Run Code Online (Sandbox Code Playgroud)
我需要知道这是否可能,我可以在没有插件的情况下完成吗?如果有的话,是否有人知道我可以遵循的良好链接/教程?
在此先感谢您的亲切问候
更新添加了我的代码并对请求进行了一些更改