邮件发-不同邮件发不同人(从excel,利用outlook)
Public Function SendMail(strFrom As String, strTo As String, _
strCC As String, _
strBCC As String, _
strSubject As String, _
strBody As String, _
strFilename As String _
) As Boolean
Dim oOutlookApp    As New Outlook.Application
Dim oItemMail    As Outlook.MailItem
Set oItemMail = oOutlookApp.CreateItem(olMailItem)
陈思诚聊天记录
On Error GoTo errHandle
If Len(Trim(strFilename)) = 0 Then
With oItemMail
'.Recipients
.SentOnBehalfOfName = strFrom
.To = strTo
西湖大学成立
.CC = strCC
.BCC = strBCC
.Subject = strSubject
.Body = strBody
'.Attachments.Add (strFilename)
.Importance = olImportanceHigh
.
Sensitivity = olPersonal
.Send
End With
Else
With oItemMail
'.Recipients
.SentOnBehalfOfName = strFrom
.To = strTo
.CC = strCC
.BCC = strBCC
.Subject = strSubject
.
Body = strBody
.Attachments.Add (strFilename)
.Importance = olImportanceHigh
.Sensitivity = olPersonal
.Send
End With
End If
SendMail = True
Exit Function
errHandle:
SendMail = False
End Function
Public Function CheckMail(strFrom As String, strTo As String, _
strCC As String, _
strBCC As String, _
strSubject As String, _
strBody As String, _
strFilename As String _
) As Boolean
Dim oOutlookApp  As New Outlook.Application
Dim oItemMail    As Outlook.MailItem
科目三灯光模拟考试
Set oItemMail = oOutlookApp.CreateItem(olMailItem)
On Error GoTo errHandle
If Len(Trim(strFilename)) = 0 Then
手动挡自动挡With oItemMail
'.Recipients
.SentOnBehalfOfName = strFrom
.To = strTo
.CC = strCC
.BCC = strBCC
.Subject = strSubject
.Body = strBody
'.Attachments.Add (strFilename)
.
Importance
= olImportanceHigh
.Sensitivity = olPersonal
'                    .Display
.Save
End With
自己包的粽子要煮多久才能熟Else
With oItemMail
'.Recipients
.SentOnBehalfOfName = strFrom
.To = strTo
.
CC = strCC
.BCC = strBCC
.Subject = strSubject
.Body = strBody
.Attachments.Add (strFilename)
.Importance = olImportanceHigh
.Sensitivity = olPersonal
'                  .Display
.Save
End With
End If
CheckMail = True
Exit Function
errHandle:
CheckMail = False
End Function
Sub SendMailNow()
Dim ExcelSheet As Object
Dim rowCount As Integer
Dim i As Integer
Set ExcelSheet = CreateObject("c:\email.xls")
rowCount = ExcelSheet.sheets(1).UsedRange.Rows.Count
For i = 2 To rowCount
SendMail strFrom:=ExcelSheet.sheets(1).cells(i, 1), strTo:=ExcelSheet.sheets(1).cells(i, 2), _
strCC:=ExcelSheet.sheets(1).cells(i, 3), strBCC:=ExcelSheet.sheets(1).cells(i, 4), _
strSubject:=ExcelSheet.sheets(1).cells(i, 5), strBody:=ExcelSheet.sheets(1).cells(i, 6), _
strFilename:=ExcelSheet.sheets(1).cells(i, 7)
Next i
ExcelSheet.Close False
Set ExcelSheet = Nothing
End Sub
烧茄子的做法大全Sub CheckMailNow()
aa = Timer
Dim ExcelSheet As Object
Dim rowCount As Integer
Dim i As Integer
Set ExcelSheet = CreateObject("c:\email.xls")
rowCount = ExcelSheet.sheets(1).UsedRange.Rows.Count
For i = 2 To rowCount
CheckMail strFrom:=ExcelSheet.sheets(1).cells(i, 1), strTo:=ExcelSheet.sheets(1).cells(i, 2), _
strCC:=ExcelSheet.sheets(1).cells(i, 3), strBCC:=ExcelSheet.sheets(1).cells(i, 4), _
strSubject:=ExcelSheet.sheets(1).cells(i, 5), strBody:=ExcelSheet.sheets(1).cells(i, 6), _
strFilename:=ExcelSheet.sheets(1).cells(i, 7)
Next i
ExcelSheet.Close False
Set ExcelSheet = Nothing
MsgBox "Total Time :=  " & Format(Timer - aa, "0.00") & "s"
End Sub

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。