Access 2010 - VBA - 如何使用Outlook发送电子邮件?它只是在发件箱里! [英] Access 2010 - VBA - How can I send email with Outlook? It just sits in outbox!

查看:209
本文介绍了Access 2010 - VBA - 如何使用Outlook发送电子邮件?它只是在发件箱里!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好。对于VBA来说,我是一个完整的菜鸟。我有一些代码,我上网通过Access 2010使用Outlook发送电子邮件。代码通过显示Outlook消息窗口工作,但消息位于发件箱中,直到我打开Outlook。无论如何都要保持Outlook打开足够长的时间来发送消息。我问的原因是因为这个数据库将用于工作,我不能保证这些人将打开Outlook来完成消息发送过程。


这是我到目前为止所拥有的。我还没有在消息中添加任何内容,因为我还在测试:

展开 | 选择 | Wrap | 行号

解决方案

如果你只发送一个报告,查询等...然后 DoCmd.SendObject(obj的类型),(obj的名称),(发送obj的格式),(发送到sendto的电子邮件),,, zsubject,zmessage,True 将是最简单的[F1]来获取详细信息。


否则,你将成为想要对你的代码进行一些更改。


我不需要发送任何物体。消息正文将包含来自原始表单的字段的信息。我只需要保持Outlook打开足够长的时间来发送消息。


OutApp需要维护在程序完成后不会死的地方。持久性(Not object related)模块中的 Public 变量可以解决这个问题。


使用应用程序自动化,与实际代码中的任何内容一样,您应该采用可重新配置来确保所有使用的对象在完成时整齐关闭。这意味着确保Outlook在完成后关闭。


Hi there. I''m a complete noob when it comes to VBA. I have some code that I got online to send an email using Outlook through Access 2010. The code works by displaying an Outlook message window, but the message sits in the outbox until I open Outlook. Is there anyway to keep Outlook open long enough for the message to send. The reason I am asking is because this database will be used in work and I cannot guarantee that the guys will open Outlook to complete the message sending process.

Here is what I have so far. I have not added any content to the message yet as I am still testing:

Expand|Select|Wrap|Line Numbers

解决方案

If you''re sending only a single report, query etc... then the DoCmd.SendObject (type of obj), (name of obj), (format to send obj), (email to sendto), , , zsubject, zmessage, True would be the simplest [F1] to get the details.

Otherwise, you''ll be wanting a more than a few changes to your code.


I don''t need to send any objects. The body of the message will contain info on the fields from the originating form. I just need to keep Outlook open long enough for the message to send.


OutApp needs to be maintained somewhere that won''t die as soon as the procedure is finished. A Public variable in a persistent (Not object related) module would do the trick.

With Application Automation though, as with anything in code really, you should take resoponsibility for ensuring all objects used are closed tidily when finished with. This means ensuring Outlook is closed when it''s finished with.


这篇关于Access 2010 - VBA - 如何使用Outlook发送电子邮件?它只是在发件箱里!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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