在 Send 方法失​​败的情况下使用 Outlook 发送邮件 [英] Sending mail using Outlook where the Send method fails

查看:22
本文介绍了在 Send 方法失​​败的情况下使用 Outlook 发送邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用此代码从 Excel 发送电子邮件:

I use this code to send email from 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:	est.txt")
        .Send ' <--------------------------------This is causing troubble
    End With
    On Error GoTo 0

    Set OutMail = Nothing
    Set OutApp = Nothing
End Sub

问题在于 .Send 未被识别为对象(或方法).

The problem is that .Send is not recognized as an object (or method).

其他命令正在运行(即显示、保存).

Other commands are working (i.e. Display, Save).

我相信这个错误的存在是因为我工作中的安全系统.我什至尝试过使用 CDO,但它无法正常工作.

I believe this error exists because of security systems at my work. I have even tried using CDO and it is not working ether.

推荐答案

.Send 更改为 .Display 并放入 SendKeys "^{ENTER}"With OutMail 行之前.

Change .Send to .Display and put SendKeys "^{ENTER}" before the With OutMail line.

这篇关于在 Send 方法失​​败的情况下使用 Outlook 发送邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆