[Access VBA] Send Email from Access VBA
by 艾鍗學院, 2012-12-11 20:01, 人氣(1938)
Private Sub Command0_Click()
Dim olApp As Object
Dim objMail As Object
On Error Resume Next 'Keep going if there is an error
Set olApp = GetObject(, "Outlook.Application") 'See if Outlook is open
If Err Then 'Outlook is not open
Set olApp = CreateObject("Outlook.Application") 'Create a new instance of Outlook
End If
'Create e-mail item
Set objMail = olApp.CreateItem(olMailItem)
With objMail
'Set body format to HTML
.BodyFormat = olFormatHTML
.To = "your email; your second email"
.Subject = "Subject"
.HTMLBody = "<HTML><H2>The body of this message will appear in HTML.</H2><BODY>Type the message text here. </BODY></HTML>"
'.Send ' 直接寄出
.Display ' 顯示outlook
End With
參考資料: http://msdn.microsoft.com/en-us/library/office/ff861332.aspx