Outlook 2013 使用 VBA 发送草稿 [英] Outlook 2013 using VBA to Send Drafts

查看:120
本文介绍了Outlook 2013 使用 VBA 发送草稿的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

早上好,

我使用 Outlook 2010 编译代码以发送保存在给定帐户的草稿文件夹中的所有电子邮件.现在我已经升级到 Office 2013 我收到一个错误...它是 .Send 位,它失败并显示错误消息:

Using Outlook 2010 I compiled code to send all emails that were saved in a drafts folder of a given account. Now I've upgraded to Office 2013 I am getting an error... It is the .Send bit where it falls over and presents the error message:

此方法不能用于内嵌响应邮件项."

"This method can't be used with an inline response mail item."

我确信有一种简单的发送草稿的方法,但我已经在网上搜索过,但仍然无法弄清楚.

I am certain that there is a v simple method for sending drafts, but I have scoured the web and can't figure it as yet.

Public Sub SendDrafts()

Dim lDraftItem As Long
Dim myOutlook As Outlook.Application
Dim myNameSpace As Outlook.NameSpace
Dim myFolders As Outlook.Folders
Dim myDraftsFolder As Outlook.MAPIFolder

'Send all items in the "Drafts" folder that have a "To" address filled

'Setup Outlook

Set myOutlook = Outlook.Application
Set myNameSpace = myOutlook.GetNamespace("MAPI")
Set myFolders = myNameSpace.Folders

'Set Draft Folder. This will need modification based on where it's


Set myDraftsFolder = myFolders("accounts@credec.co.uk").Folders("Drafts")

'Loop through all Draft Items

For lDraftItem = myDraftsFolder.Items.count To 1 Step -1

'Check for "To" address and only send if "To" is filled in.

If Len(Trim(myDraftsFolder.Items.Item(lDraftItem).To)) ] 0 Then

'Send Item

myDraftsFolder.Items.Item(lDraftItem).Send

End If
Next lDraftItem

'Clean-up

Set myDraftsFolder = Nothing
Set myNameSpace = Nothing
Set myOutlook = Nothing

End Sub

推荐答案

我知道这是旧的,但万一其他人正在寻找答案:

I know this is old, but in case someone elses is looking for an answer:

活动内联响应"是指在 Outlook 中打开的草稿.因此,在调试时,请关闭草稿并翻回另一条消息.然后看看你的代码能不能运行.

"Active Inline Response" refers to a draft that is open in Outlook. So, when you are debugging, close the draft and flip back to a different message. Then see if your code will run.

这篇关于Outlook 2013 使用 VBA 发送草稿的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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