如何解决您能否根据 If Len 语句的结果设置不同的电子邮件主题行?
所以这段代码非常适合我。它根据我的 If Len 语句发送电子邮件。在电子邮件正文中,它列出了哪些工作表提示了电子邮件,因为它们会不断变化。我还希望在电子邮件的主题行中列出这些工作表,但不知道如何操作。
Sub Main()
Dim sh As Worksheet,i As Long,shtsRotations As String
Dim shtsFunctions As String,shtsOK As String
For Each sh In ActiveWorkbook.Worksheets
If Application.CountIf(sh.Range("L3:L70"),"<1") > 0 Then
shtsRotations = shtsRotations & vbLf & sh.Name
Else
shtsOK = shtsOK & vbLf & sh.Name & " (Rotations)"
End If
If Application.CountIf(sh.Range("M3:M70"),"<1") > 0 Then
shtsFunctions = shtsFunctions & vbLf & sh.Name
Else
shtsOK = shtsOK & vbLf & sh.Name & " (Functions)"
End If
Next sh
If Len(shtsRotations) > 0 Then
SendReminderMail "test@test.com","Equipment rotations are due!" & shtsRotations,_
"Hello Team," & vbNewLine & vbNewLine & _
"Check customer sheets: " & shtsRotations & vbLf & vbNewLine & _
"In the attatched workbook,you will see which equipment needs to be rotated by the red dates of their last rotation."
End If
If Len(shtsFunctions) > 0 Then
SendReminderMail "test@test.com","Equipment functions are due! "," & vbNewLine & vbNewLine & _
"Check customer sheets: " & shtsFunctions & vbLf & vbNewLine & _
"In the attatched workbook,you will see which equipment needs to be functioned by the red dates,indicating their last function."
End If
If Len(shtsOK) > 0 Then
MsgBox "These sheets are OK: " & vbLf & shtsOK,vbInformation
End If
End Sub
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。