我的VBA完美地合并了电子邮件...除了,我必须点击"允许" - 从Outlook - 两次,为每个生成的电子邮件。有没有办法以编程方式解决这个问题?
我正在运行Windows 7 Enterprise,SP1。 MS Office 2007.计算机被严格锁定。不支持HTML格式的电子邮件 - 仅限纯文本。我没有本地管理员权限。我无法安装其他加载项或第三方软件,因为我发现了很多次。
这是我工作的VBA: Private Sub 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
End Sub
感谢任何帮助。
答案 0 :(得分:0)
您可以直接从Access自动执行。有关详细信息,请参阅How to automate Outlook from another program。它描述了从其他应用程序自动化Outlook所需的所有步骤。