Set OutApp = CreateObject("Outlook.Application")
MsgBox (OutApp Is Nothing)
On Error GoTo errorHandler
Set OutMail = OutApp.CreateItem(0)
'OutMail.Parent.Display '****
On Error Resume Next
With OutMail
.To = cell.Value
.Subject = "Subject"
.Body = "Body"
.Se
End With
On Error GoTo errorHandler
Set OutMail = Nothing
如果我想要发送电子邮件,我必须取消注释OutMail.Parent.Display
行。我为什么要通过让Outlook可见来惹恼用户呢?这是安全设置还是什么?
答案 0 :(得分:0)
不,没有必要:)另外我猜.Se
是问题中提到的代码中的拼写错误?
这适合我。
Option Explicit
Sub Sample()
Dim OutApp As Object, OutMail As Object
On Error GoTo Whoa
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
With OutMail
.To = cell.Value
.Subject = "Subject"
.Body = "Body"
.Send '<~~ .Display to display
End With
LetsContinue:
Set OutMail = Nothing
Set OutApp = Nothing
Exit Sub
Whoa:
MsgBox Err.Description
Resume LetsContinue
End Sub