Excel的VBA发邮件里面加入excel里面的数据给指定的人 5
怎么用outlookVBA把指定的excel数据发给指定的人,如下图,所有内容(不包含status为Closed的数据)会发给指定的人,比如我是YuYuanDing(标题...
怎么用outlook VBA把指定的excel数据发给指定的人,如下图,所有内容(不包含status为Closed的数据)会发给指定的人,比如我是YuYuan Ding(标题为Assignee的数据),所有整行包括YuYuan Ding的数据包括表格里的标题就会发给YuYuan Ding(不包括status为Closed的数据),
现在我只做到可以发给指定的人,就是Sheet2里面的数据通过合并进Sheet4来发送,却不知道怎么把和指定的人相关的表格数据内容放进邮件的内容里,求大神帮打下,万分感谢!
Sub Email()
Dim OutApp As Object
Dim OutMail As Object
Dim cell As Range
Sheets("Sheet2").SelectActiveSheet.Range($A$1:$J$6).AutoFilter Field:=3,Criterial1:=_
"=In Progress", Operator:=xlOr,Criteria2:="=Resolved"Columns("G:G").Select
Selection.Copy
Sheets("Sheet4").Select
Columns("A:A").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveSheet.Range("$A$1:$A$1048574").RemoveDuplicates Columns:=1, Header:=_
xlYes
Sheets("Sheet4").Select
Application.ScreenUpdating = False
Set OutApp = CreateObject("Outlook.Application")
On Error GoTo cleanup
For Each cell In Columns("A").Cells.SpecialCells(xlCellTypeConstants)
If (Cells(cell.Row, "A").Value) <> "" Then
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.To = cell.Value
.Subject = "Please looking ofr these defects"
.Body = "Hi," & Cells(cell.Row, "A").Value _
& vbNewLine & vbNewLine & _
"These are the defects."
.Send
End With
On Error GoTo 0
Set OutMail = Nothing
End If
Next cell
cleanup:
Set OutApp = Nothing
Application.ScreenUpdating = True
End Sub 展开
现在我只做到可以发给指定的人,就是Sheet2里面的数据通过合并进Sheet4来发送,却不知道怎么把和指定的人相关的表格数据内容放进邮件的内容里,求大神帮打下,万分感谢!
Sub Email()
Dim OutApp As Object
Dim OutMail As Object
Dim cell As Range
Sheets("Sheet2").SelectActiveSheet.Range($A$1:$J$6).AutoFilter Field:=3,Criterial1:=_
"=In Progress", Operator:=xlOr,Criteria2:="=Resolved"Columns("G:G").Select
Selection.Copy
Sheets("Sheet4").Select
Columns("A:A").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveSheet.Range("$A$1:$A$1048574").RemoveDuplicates Columns:=1, Header:=_
xlYes
Sheets("Sheet4").Select
Application.ScreenUpdating = False
Set OutApp = CreateObject("Outlook.Application")
On Error GoTo cleanup
For Each cell In Columns("A").Cells.SpecialCells(xlCellTypeConstants)
If (Cells(cell.Row, "A").Value) <> "" Then
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.To = cell.Value
.Subject = "Please looking ofr these defects"
.Body = "Hi," & Cells(cell.Row, "A").Value _
& vbNewLine & vbNewLine & _
"These are the defects."
.Send
End With
On Error GoTo 0
Set OutMail = Nothing
End If
Next cell
cleanup:
Set OutApp = Nothing
Application.ScreenUpdating = True
End Sub 展开
展开全部
数据规则,建议使用word【邮件合并】
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询