2
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 可见来惹恼用户呢?这是安全设置还是什么?

4

1 回答 1

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
于 2012-05-25T13:25:40.820 回答