Sub Auto_SendMail()
On Error Resume Next
Dim objOutlook As Object
Dim objMail As Object
Set objOutlook = CreateObject("Outlook.Application")
Set objMail = objOutlook.CreateItem(olMailItem)
Sheets("Setting Sheet").Select
Email = ""
Email_cc = ""
'確認收件人與副件人員名單是否是空的
If WorksheetFunction.CountA(Columns(18)) < WorksheetFunction.CountA(Columns(19)) Then
MsgBox "抄送人数不可大于正常收件者人数,请重新确认,谢谢。"
Set objMail = Nothing
Set objOutlook = Nothing
Exit Sub
Else
If WorksheetFunction.CountA(Columns(18)) <= 1 Then
MsgBox "正常收件者人数不得为空,请重新确认,谢谢。"
Set objMail = Nothing
Set objOutlook = Nothing
Exit Sub
End If
End If
For r = 2 To WorksheetFunction.CountA(Columns(18))