MS Access VBA:通过Outlook发送电子邮件 [英] MS Access VBA: Sending an email through Outlook

查看:116
本文介绍了MS Access VBA:通过Outlook发送电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用MS Access VBA通​​过帐户发送电子邮件?我知道这个问题含糊不清,但是很难在网上找到没有以某种方式过时的相关信息.

How can I send an email through an account using MS Access VBA? I know this question is vague but it's so hard to find the relevant information online that isn't outdated in some way.

我并不是要对那些要回答的人不礼貌,但是我正在使用MS Access .我无法在Outlook VBA中编写实际的代码.

I don't mean to be rude to those who are answering, but I am using MS Access. I cannot write the actual code in Outlook VBA.

推荐答案

在Visual Basic编辑器中添加对Outlook对象模型的引用.然后,您可以使用下面的代码使用Outlook发送电子邮件.

Add a reference to the Outlook object model in the Visual Basic editor. Then you can use the code below to send an email using outlook.

Sub sendOutlookEmail()
Dim oApp As Outlook.Application
Dim oMail As MailItem
Set oApp = CreateObject("Outlook.application")

Set oMail = oApp.CreateItem(olMailItem)
oMail.Body = "Body of the email"
oMail.Subject = "Test Subject"
oMail.To = "Someone@somewhere.com"
oMail.Send
Set oMail = Nothing
Set oApp = Nothing


End Sub

这篇关于MS Access VBA:通过Outlook发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆