为什么这个VB脚本不发送电子邮件?

我在Excel中有以下脚本,它应该发送一个电子邮件(收件人应该在B24),但我没有收到错误信息,但电子邮件也没有交付。 任何帮助将非常感激。

有人可以向我解释什么是错的,或者我在这里做错了什么?

Sub Email2() Dim sh As Worksheet Dim wb As Workbook Dim FileExtStr As String Dim FileFormatNum As Long Dim TempFilePath As String Dim TempFileName As String Dim OutApp As Object Dim OutMail As Object TempFilePath = Environ$("temp") & "\" If Val(Application.Version) < 12 Then FileExtStr = ".xls": FileFormatNum = -4143 Else FileExtStr = ".xlsm": FileFormatNum = 52 End If With Application .ScreenUpdating = False .EnableEvents = False End With Set OutApp = CreateObject("Outlook.Application") For Each sh In ThisWorkbook.Worksheets If sh.Range("B28").Value Like "?*@?*.?*" Then sh.Copy Set wb = ActiveWorkbook TempFileName = "Performance " & sh.Name & " date " & Format(Now, "dd-mmm-yy h-mm-ss") Set OutMail = OutApp.CreateItem(0) With wb .SaveAs TempFilePath & TempFileName & FileExtStr, FileFormat:=FileFormatNum On Error Resume Next With OutMail .TO = sh.Range("B24").Value .CC = "" .BCC = "" .Subject = "This is the subject" .Body = "Hello," .Attachments.Add wb.FullName .Send End With On Error GoTo 0 .Close savechanges:=False End With Set OutMail = Nothing Kill TempFilePath & TempFileName & FileExtStr End If Next sh Set OutApp = Nothing With Application .ScreenUpdating = True .EnableEvents = True End With End Sub 

您提供的代码在Excel 2010上为我工作。

我所能看到的只是检查“B28”中的值是否为电子邮件地址,然后将电子邮件发送到“B24”中的地址。 这是问题吗?

对于我的testing,我把地址写在“B28”和“B24”中。