以下是我通过 ms access
vba
Outlook
发送附件的代码。此代码运行良好。
我的问题:当我运行此代码时,它首先打开 Outlook composer,然后我们必须按下发送按钮。是否可以在不打开 Outlook 撰写屏幕的情况下发送邮件?
Private Sub Command7_Click()
Dim FileName As String
Dim FilePath As String
Dim oOutlook As Outlook.Application
Dim oEmailItem As MailItem
FileName = Me.nametxt
FilePath = "N:\UAE\Dubai\Xfer\Libin\pdf\" & FileName & ".pdf"
DoCmd.OutputTo acOutputReport, "Form", acFormatPDF, FilePath
If oOutlook Is Nothing Then
Set oOutlook = New Outlook.Application
End If
Set oEmailItem = oOutlook.CreateItem(olMailItem)
With oEmailItem
.To = Me.Combo1
.CC = ""
.Subject = "Cust"
.Attachments.Add FilePath
.Display
End With
Set oEmailItem = Nothing
Set oOutlook = Nothing
'Kill FilePath
End Sub