外观主题和发送邮件Outlook VBA

外观主题和发送邮件Outlook VBA,vba,outlook,Vba,Outlook,我正在尝试创建一个宏,它将在消息的主题中添加一些文本,然后发送消息。我在功能区上创建了一个按钮,用户可以单击该按钮将其添加(安全)到主题行并发送消息 我正在使用以下我从网上找到的几个来源收集的信息 Sub InsertSubject() Dim objMsg As Outlook.MailItem 'Get the currently open message' Set objMsg = Outlook.Application.ActiveInspector.CurrentItem ob

我正在尝试创建一个宏,它将在消息的主题中添加一些文本,然后发送消息。我在功能区上创建了一个按钮,用户可以单击该按钮将其添加(安全)到主题行并发送消息

我正在使用以下我从网上找到的几个来源收集的信息

Sub InsertSubject()

Dim objMsg As Outlook.MailItem

'Get the currently open message'

Set objMsg = Outlook.Application.ActiveInspector.CurrentItem

objMsg.Subject = CurrentItem.Subject & "(Secure) "

'Destroy the object to avoid memory leaks'
objMsg.Send
Set objMsg = Nothing


End Sub
当我运行这个时,我得到一个运行时错误424对象。它似乎与以下行有问题

objMsg.Subject = CurrentItem.Subject & "(Secure) "
如果我删除CurrentItem.Subject,代码可以工作,但显然只是用(Secure)替换了以前的主题


任何帮助都将不胜感激。

我想您打算这样做
objMsg.Subject=objMsg.Subject&“(安全)”


请注意,您尝试使用的是
CurrentItem
,它不一定与
Outlook.Application.ActiveInspector.CurrentItem
相同。我不太熟悉Outlook对象模型,但我敢打赌,单独调用它时,
CurrentItem
是无效的。

就是这样。谢谢你的解释,这很有道理。