Excel电子邮件悬挂Outlook直到发送 – error handling?

我使用下面的macros发送Excel工作簿。 我使用空白的电子邮件地址,以便在Outlook中显示电子邮件,并允许用户input电子邮件地址。 但是,除非发送或closures电子邮件而不发送,否则Excel不会让用户在Outlook中执行其他操作,甚至打开附件进行检查。 它不会closures文件,直到电子邮件被处理,所以它被困在这个循环中。 我怎样才能解决这个问题?

TempFilePath = Environ$("temp") & "\" TempFileName = "The File Name" FileExtStr = ".xlsx" With TheWorkbook .SaveAs TempFilePath & TempFileName & FileExtStr, FileFormat:=FileFormatNum On Error Resume Next For I = 1 To 3 .SendMail "", _ "This is the Subject line" If Err.Number = 0 Then Exit For Next I On Error GoTo 0 .Close SaveChanges:=False End With 

而不是.SendMail为什么不与Outlook展开合作? 这样,Excel就不用等待行动完成了?

看到这个例子

 Option Explicit Sub Sample() Dim OutApp As Object Dim OutMail As Object Dim i As Long Set OutApp = CreateObject("Outlook.Application") Set OutMail = OutApp.CreateItem(0) With ThisWorkbook ' '~~> Do Something ' For i = 1 To 3 Set OutMail = OutApp.CreateItem(0) With OutMail .Subject = "This is the Subject line" .Body = "Hello World" .Attachments.Add TempFilePath & TempFileName & FileExtStr '~~> Show the email .Display End With Next i End With End Sub