【发布时间】:2025-12-01 02:25:01
【问题描述】:
我的 VBA 可以很好地合并电子邮件...除了,对于生成的每封电子邮件,我必须在 Outlook 中单击“允许”两次。有没有办法以编程方式解决这个问题?
我正在运行 Windows 7 企业版 SP1。 MS Office 2007。计算机被紧紧锁定。不支持 HTML 格式的电子邮件 - 仅支持纯文本。我没有本地管理员权限。正如我多次发现的那样,我无法安装其他插件或第三方软件。
这是我的工作 VBA: 私人订阅 Send_Email_Merge()
Dim sDBPath As String
'Word variables
Dim oWD As Word.Application
Dim oDoc As Word.Document
Dim RecCount As Long
'Sanity check on how many e-mails to be sent
RecCount = DLookup("[Email Count]", "qry_EmailMerge_Count")
Debug.Print RecCount
Set oWD = CreateObject("Word.Application")
oWD.Visible = True
Set oDoc = oWD.Documents.Open("C:\MyTemp\MyDocs\MyEmailMerge.docx")
With oDoc.MailMerge
.MainDocumentType = wdFormLetters
sDBPath = "C:\MyTemp\MydBs\My_Engine.accdb"
.OpenDataSource Name:=sDBPath, _
SQLStatement:="SELECT * FROM [qry_E Mail Merge]"
End With
oWD.Activate
oWD.Documents.Parent.Visible = True
oWD.Application.WindowState = 1
oWD.ActiveWindow.WindowState = 1
With oDoc.MailMerge
.Destination = wdSendToEmail
.MailAddressFieldName = "Email Address"
.MailSubject = "Your Action Required"
.MailFormat = wdMailFormatPlainText
.Execute
End With
oWD.Activate
oWD.Documents.Parent.Visible = True
oWD.Application.WindowState = 1
oWD.ActiveWindow.WindowState = 1
oWD.ActiveDocument.Close
oWD.Quit
Set oWD = Nothing
Set oDoc = Nothing
结束子
感谢任何帮助。
【问题讨论】:
标签: email ms-word ms-access-2007 outlook-2007 mailmerge