[英]How to Send All Emails From Outlook Outbox in VBA
I'm using Excel VBA to stage emails in Outlook and it is working well. 我正在使用Excel VBA在Outlook中暂存电子邮件,并且运行良好。
Dim template As Outlook.MailItem, tomerge As Outlook.MailItem
' Create E-mail
tomerge.Close olSave
The e-mails can then be manually moved to the Drafts folder and sent using this Sub . 然后可以将电子邮件手动移动到“草稿”文件夹并使用此Sub发送 。
'Loop through items in Drafts folder
objDrafts.Item(i).Send
However, many users have a bunch of extra drafts in their Drafts folder that they don't want sent. 但是,许多用户在“草稿”文件夹中有一堆不想发送的多余草稿。
If I replace "olFolderDrafts" with "olFolderOutbox" and try to send from their Outbox. 如果我将“ olFolderDrafts”替换为“ olFolderOutbox”,并尝试从其发件箱发送邮件。 The first message sends and then I get a "Run-time error" "Outlook has already begun transmitting this message".
发送第一个消息,然后出现“运行时错误”“ Outlook已经开始发送此消息”。
Is there some way to send all from the Outbox or even better is there someway to stage and send from a newly created folder? 是否可以通过某种方式从发件箱发送所有邮件, 或者更好的是可以通过某种方式登台并从新创建的文件夹发送邮件?
You need to create a folder for your unsent items and process them separately. 您需要为未发送的项目创建一个文件夹,并分别进行处理。 As a rule the
Outbox
folder contains already submitted items. 通常,
Outbox
文件夹包含已提交的项目。 So, that's not a right place for your items. 因此,这不是您放置物品的合适位置。
The Outlook Object Model provides the Add function of the Folders
class. Outlook对象模型提供
Folders
类的Add函数。 You can get an instance of the Folders
class using the Folders
property of the Folder
class in Outlook. 您可以使用Outlook中
Folder
类的Folders
属性获取Folders
类的实例。 You can read more about that in the How To: Create a new folder in Outlook article. 您可以在如何:在Outlook中创建新文件夹文章中了解有关此内容的更多信息。
This answer was inspired by Nagarajan's comment above, but there are quite a few changes necessary from the answer in Send/Receive in Outlook Via Code . 这个答案的灵感来自Nagarajan的上述评论,但是与Outlook Via Code中的Send / Receive中的答案相比,还需要进行很多更改。 The main problem is using
olSave
doesn't put the messages in a "ready to send" state in Outlook so starting a sync using syc.Start
from the answer above does nothing. 主要问题是使用
olSave
不会在Outlook中将邮件置于“准备发送”状态,因此使用syc.Start
。开始同步从上面的答案起什么都没有做。
Instead, we found the following process to be straight forward: 相反,我们发现以下过程很简单:
.Send
each email. .Send
电子邮件,而不是仅.Send
。 .Send
每封电子邮件。 As Outlook is offline they will be staged and ready to be sent but not actually sent.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.