Vba 有没有一种方法可以从Access 2002创建新的Outlook电子邮件而不使用SendObject命令?

Vba 有没有一种方法可以从Access 2002创建新的Outlook电子邮件而不使用SendObject命令?,vba,ms-access,outlook,email-attachments,Vba,Ms Access,Outlook,Email Attachments,我有一个客户端正在使用Access 2002,因为它允许复制。他正在Windows 10上使用Office 365的Outlook 我们的目标是创建一封包含所有信息的新电子邮件,并附上一份扫描过的提案,以便我的客户可以查看该电子邮件,进行任何他想要的更改,然后发送它 在Access中,SendObject命令创建并打开一封纯文本电子邮件,当此电子邮件处于打开状态时,扫描文档并将其附加到电子邮件的my Outlook宏将不会运行 因此,我想从Access创建一封新的Outlook电子邮件,允许我运

我有一个客户端正在使用Access 2002,因为它允许复制。他正在Windows 10上使用Office 365的Outlook

我们的目标是创建一封包含所有信息的新电子邮件,并附上一份扫描过的提案,以便我的客户可以查看该电子邮件,进行任何他想要的更改,然后发送它

在Access中,SendObject命令创建并打开一封纯文本电子邮件,当此电子邮件处于打开状态时,扫描文档并将其附加到电子邮件的my Outlook宏将不会运行

因此,我想从Access创建一封新的Outlook电子邮件,允许我运行Outlook宏

Private Sub EmailProposal_Click() 
'Access macro.
Dim stDocName As String
Dim stEmailAddress As String
Dim stSubject As String
Dim stMessage As String

    stDocName = "rptProposal"
    stEmailAddress = Forms!RequestForm!EmailAddress.Value
    stSubject = "PROPOSAL"
    stMessage = "Your proposal is attached." & vbCrLf & vbCrLf & "If you have any questions, please call us."

    'Email the proposal.
    DoCmd.SendObject acReport, stDocName, acFormatRTF, stEmailAddress, , , stSubject, stMessage
End Sub

Sub Scan()
'Outlook macro.
Dim myItem As Outlook.MailItem
Dim myAttachments As Outlook.Attachments

     On Error Resume Next
     Dim objCommonDialog As WIA.CommonDialog
     Dim objImage As WIA.ImageFile
     Dim strPath As String

     Set objCommonDialog = New WIA.CommonDialog
     'This shows the dialog box. I'd rather tell it what to do instead of having to manually choose each time.
     Set objImage = objCommonDialog.ShowAcquireImage        

     strPath = Environ("TEMP") & "\TempScan.jpg"            'Save the scan.
     If Not objImage Is Nothing Then
         objImage.SaveFile strPath        ' save into temp file
         On Error GoTo ErrHandler

         If TypeName(ActiveWindow) = "Inspector" Then
             If ActiveInspector.IsWordMail And ActiveInspector.EditorType = olEditorWord Then
               ActiveInspector.WordEditor.Application.Selection.Inlineshapes.AddPicture strPath        'Insert into email. I want to attach it instead.
             End If
         End If
         Kill strPath
     Else
        MsgBox "The Scan macro in Outlook did not find a document." & vbCrLf & vbCrLf & _ 
        "Please place the proposal in the printer so it can be scanned.", vbOKOnly
     End If

lbl_Exit:
     Set objImage = Nothing
     Set objCommonDialog = Nothing
     Exit Sub

ErrHandler:
     Beep
     Resume lbl_Exit
End Sub
或者,如果我可以获得Access 2002来创建电子邮件并将扫描的文档附加到其中,我想我可以使用msgboxes来验证特定的项目

下面是Access宏,其SendObject命令后跟Outlook宏

Private Sub EmailProposal_Click() 
'Access macro.
Dim stDocName As String
Dim stEmailAddress As String
Dim stSubject As String
Dim stMessage As String

    stDocName = "rptProposal"
    stEmailAddress = Forms!RequestForm!EmailAddress.Value
    stSubject = "PROPOSAL"
    stMessage = "Your proposal is attached." & vbCrLf & vbCrLf & "If you have any questions, please call us."

    'Email the proposal.
    DoCmd.SendObject acReport, stDocName, acFormatRTF, stEmailAddress, , , stSubject, stMessage
End Sub

Sub Scan()
'Outlook macro.
Dim myItem As Outlook.MailItem
Dim myAttachments As Outlook.Attachments

     On Error Resume Next
     Dim objCommonDialog As WIA.CommonDialog
     Dim objImage As WIA.ImageFile
     Dim strPath As String

     Set objCommonDialog = New WIA.CommonDialog
     'This shows the dialog box. I'd rather tell it what to do instead of having to manually choose each time.
     Set objImage = objCommonDialog.ShowAcquireImage        

     strPath = Environ("TEMP") & "\TempScan.jpg"            'Save the scan.
     If Not objImage Is Nothing Then
         objImage.SaveFile strPath        ' save into temp file
         On Error GoTo ErrHandler

         If TypeName(ActiveWindow) = "Inspector" Then
             If ActiveInspector.IsWordMail And ActiveInspector.EditorType = olEditorWord Then
               ActiveInspector.WordEditor.Application.Selection.Inlineshapes.AddPicture strPath        'Insert into email. I want to attach it instead.
             End If
         End If
         Kill strPath
     Else
        MsgBox "The Scan macro in Outlook did not find a document." & vbCrLf & vbCrLf & _ 
        "Please place the proposal in the printer so it can be scanned.", vbOKOnly
     End If

lbl_Exit:
     Set objImage = Nothing
     Set objCommonDialog = Nothing
     Exit Sub

ErrHandler:
     Beep
     Resume lbl_Exit
End Sub

看起来,您只需要自动化Outlook,以发送设置了所需内容的电子邮件。请看以下文章,它们为您提供了Outlook自动化的基础知识:


它工作得很好。非常感谢!关于如何从Access运行扫描宏有什么想法吗?在Access VBA运行后,我正在新Outlook电子邮件中运行它,因此我无法从那里附加它。Access不喜欢该子系统中的AWI类型。当前,Outlook扫描子系统插入扫描的项目,而不是像我希望的那样附加它,并在我希望使用具有字母大小的进纸器时显示一个扫描仪对话框。我意识到这些都是新问题。要使WIA命令在Access中工作,请打开Microsoft Windows图像采集库的参考。若要将文件附加到打开的电子邮件中,
设置myItem=Outlook.Application.ActiveInspector.CurrentItem myItem.Attachments.Add strFileZip
其中strFileZip包含文件字符串和名称。若要设置扫描仪选项并使用进纸器,
将扫描仪设置为WIA。设备DPI=100 PP=1'页数设置扫描仪=Dialog1.ShowSelectDevice(WIA.WiaDeviceType.ScannerDeviceType,False,False)Scanner.Properties(“3088”)。Value=1'使用文档进纸器。Scanner.Items(1)。Properties(“6146”)。Value=1'颜色意图。4是bw。1是Color.Scanner.Items(1)。Properties(“6151”)。Value=8.27*DPI'水平范围扫描仪。Items(1)。Properties(“6152”).Value=11#*DPI'字母的垂直范围
等。