使用Outlook从Excel发送电子邮件而没有安全警告 [英] Sending emails from Excel using Outlook without security warning

查看:242
本文介绍了使用Outlook从Excel发送电子邮件而没有安全警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Ron de Bruin网站上的代码来使用Outlook通过Excel发送电子邮件.我收到此安全警告程序正在尝试代表您发送电子邮件",要求我允许或拒绝.

I am using code from Ron de Bruin's website to send emails through Excel using Outlook. I get this security warning "A program is trying to send e-mail message on your behalf" asking me to allow or deny.

如何避免出现此警告并直接发送电子邮件"

How can I avoid this warning and send emails directly"

注意:我正在使用Excel 2007.

Note: I am using Excel 2007.

这是代码:

Dim OutApp As Object
Dim OutMail As Object
Dim strbody As String
Dim cell As Range

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

Sheets("" & Sheet & "").Select
With Sheets("" & Sheet & "")
    strbody = ""
End With

On Error Resume Next
With OutMail
    .To = " email1@a.com"
    .CC = ""
    .BCC = ""
    .Subject = ""
    .Body = strbody
    .From = ""
    .Send
End With
On Error GoTo 0

Set OutMail = Nothing
Set OutApp = Nothing

' restore default application behavior
Application.AlertBeforeOverwriting = True
Application.DisplayAlerts = True
ActiveWindow.SelectedSheets.PrintOut Copies:=3, Collate:=True

推荐答案

除了链接 ,如果您运行的是Excel,则还可以运行Outlook .

In addition to the methods described in the link from the comment, assuming you are the sender "...asking me to allow or deny", if you have Excel running you can have Outlook already running as well.

最简单的方法是:

Set OutApp = GetObject(, "Outlook.Application") 

这篇关于使用Outlook从Excel发送电子邮件而没有安全警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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