5

このコードを使用して、Excel から電子メールを送信します。

Sub Mail_workbook_Outlook_1()
'Working in Excel 2000-2013
'This example send the last saved version of the Activeworkbook
'For Tips see: http://www.rondebruin.nl/win/winmail/Outlook/tips.htm
    Dim OutApp As Object
    Dim OutMail As Object

    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(0)

    On Error Resume Next
    With OutMail
        .to = "ron@debruin.nl"
        .CC = ""
        .BCC = ""
        .Subject = "This is the Subject line"
        .Body = "Hi there"
        .Attachments.Add ActiveWorkbook.FullName
        'You can add other files also like this
        '.Attachments.Add ("C:\test.txt")
        .Send ' <--------------------------------This is causing troubble
    End With
    On Error GoTo 0

    Set OutMail = Nothing
    Set OutApp = Nothing
End Sub

問題は.Send、オブジェクト (またはメソッド) として認識されないことです。

他のコマンドは機能しています (つまり、表示、保存)。

私の職場のセキュリティ システムが原因で、このエラーが発生していると思います。CDO を使用してみましたが、うまくいきません。

4

2 に答える 2

4

に変更.Sendして行の前に.Display置きます。SendKeys "^{ENTER}"With OutMail

于 2013-08-31T14:50:50.683 に答える