|
请哪位大虾,帮一个宏,excel中判断C列的数据如果小于O,则系统自动发送D列对应的邮箱地址,可以是每天自动发送或者是手工群发送邮件。附件是源文件和截图 |
- Sub SendMail1()
- Dim OutlookApp As Object
- Dim MailItem As Object
- Option1 = MsgBox("是否自动发送?点击确认自动发送,取消则手动群发!", vbOKCancel, "群发&手动")
-
- If Option1 = 1 Then
- For i = 2 To [a65536].End(xlUp).Row
- If Cells(i, 3) < 0 Then
- Set OutlookApp = CreateObject("Outlook.Application")
- Set MailItem = OutlookApp.CreateItem(olMailItem)
- With MailItem
- .To = Cells(i, 4)
- .Subject = "自动发送"
- .Body = "自动发送"
- .Send
- '.Display
- End With
- Set OutlookApp = Nothing
- Set MailItem = Nothing
- End If
- Next i
- Else
- For i = 2 To [a65536].End(xlUp).Row
- If Cells(i, 3) < 0 Then
- receipt = Cells(i, 4) & ";" & receipt
- End If
- Next i
- Set OutlookApp = CreateObject("Outlook.Application")
- Set MailItem = OutlookApp.CreateItem(olMailItem)
- With MailItem
- .To = receipt
- .Subject = "自动发送"
- .Body = "自动发送"
- .Display
- End With
- Set OutlookApp = Nothing
- Set MailItem = Nothing
- End If
- End Sub
复制代码
|
|