【发布时间】:2019-11-22 03:43:03
【问题描述】:
我有一个包含给定数据的工作表,
我需要使用 Microsoft Outlook 以特定日期所需的格式通过电子邮件发送数据。
假设日期是 2015 年 1 月 5 日。
这就是电子邮件的外观,
代码编写在 Excel 2007 工作簿的模块中,
Public Function FormatEmail(Sourceworksheet As Worksheet, Recipients As Range, CoBDate As Date)
Dim OutApp As Object
Dim OutMail As Object
Dim rows As Range
On Error GoTo FormatEmail_Error
Application.ScreenUpdating = False
Set OutApp = CreateObject("Outlook.Application")
For Each rows In Recipients.Cells.SpecialCells(xlCellTypeConstants)
If rows.value Like "?*@?*.?*" Then
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.To = rows.value
.Subject = "Reminder"
.Body = "Hi All, " & vbNewLine & _
vbNewLine
.display
End With
On Error GoTo 0
Set OutMail = Nothing
End If
Next rows
On Error GoTo 0
Exit Function
FormatEmail_Error:
Set OutApp = Nothing
Application.ScreenUpdating = True
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure FormatEmail of Module modOutlook"
End Function
【问题讨论】:
-
需要添加/更改什么才能仅粘贴 A 列中值为非零的行?
标签: excel vba excel-2007