我有用於發送自動電子郵件的私人子功能的代碼。我從來源皮特靠在代碼自動電子郵件功能
ACCESS 2007 - Automatically Send and Email Using Outlook Upon a Specific Event
我嘗試使用下面的代碼把它變成一個功能我自己。但它不起作用。我有一種感覺,我已經完全錯誤了。如果可能的話,我還希望電子郵件正文包含整個記錄信息。
Option Explicit
Public Started As Boolean
Public oApp As Outlook.Application
Public oItem As Outlook.MailItem
Function AutoEmail()
'Automatic Email to send notifications to selected user
If Combo99.Text = "SM" Or "TW" Or "LM" Or "LV" Or "SV" Then
On Error Resume Next
'Get Outlook if it's running
Set oApp = GetObject(, "Outlook.Application")
If Err <> 0 Then
'Outlook wasn't running, start it from code
Set oApp = CreateObject("Outlook.Application")
Started = True
End If
Set oItem = oApp.CreateItem(olMailItem)
With oItem
.To = "[email protected]"
.Subject = "AutoEmail Test"
.Body = "Please enjoy this complimentary email. If this worked please email back."
'Send the email
.Send
End With
Set oItem = Nothing
If Started Then
oApp.Quit
End If
'Display message to the user
MsgBox "A model that is on the watch list has been selected. An Automatic Email has been sent", vbOKOnly, AutoEmail
Else
'Do nothing
End If
End Function
如果我刪除IF聲明它的作品,但是這是表單提交時需要。 Combo99(名稱將很快更改)是我需要檢查不再支持的模型的位置。 – ASM2701