【问题标题】:Access 2007 to Word, Outlook for 2-step Mail MergeAccess 2007 到 Word、Outlook 的两步邮件合并
【发布时间】: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


    【解决方案1】:

    您可以直接从 Access 自动化。请参阅How to automate Outlook from another program 了解更多信息。它描述了从其他应用程序自动化 Outlook 所需的所有步骤。

    【讨论】:

    • 尤金,感谢您的回复。不幸的是,您的链接将我带到了 Outlook 2000 的参考资料,对于 Outlook 2007 来说有些过时了。
    • 到目前为止没有任何变化。