【问题标题】:How to change replyTo address with macro in Outlook 2007?如何在 Outlook 2007 中使用宏更改回复地址?
【发布时间】:2015-01-20 01:50:13
【问题描述】:

我正在使用 Outlook 2007。我只想编写一个宏来删除所有收件人并添加一个新收件人。这是我的代码:

Sub replyTo(item As Outlook.MailItem)
    Do While item.ReplyRecipients.Count() > 0
        item.ReplyRecipients.Remove (1)
    Loop
    item.ReplyRecipients.Add ("example@example.com")
    item.ReplyRecipients.ResolveAll
End Sub

我还创建了一个规则来运行这个脚本。不幸的是,当我收到邮件时,replyTo 邮件并没有变成我想要的。

【问题讨论】:

  • 我没有在代码中看到任何奇怪的地方。我唯一能建议的是在对邮件项目对象进行更改后调用 Save 方法。尝试处理 NewMailEx 事件并做同样的事情,它至少可以让你调试代码。

标签: vba outlook


【解决方案1】:

目标不明确,但是……

Sub replyToExampleImmediately(item As Outlook.mailitem)

' Ignore the sender of the item and reply to "example@example.com"

    Dim replyItem As mailitem
    Set replyItem = item.reply

    replyItem.Recipients.Remove (1)

    replyItem.Recipients.Add ("example@example.com")
    replyItem.Recipients.ResolveAll

    replyItem.Display

ExitRoutine:
    Set replyItem = Nothing

End Sub


Sub replyTosender(item As Outlook.mailitem)

' Reply to the sender of the item and
'  set the replyTo so the sender will reply to "example@example.com"

    Dim replyItem As mailitem
    Set replyItem = item.reply

    replyItem.ReplyRecipients.Add ("example@example.com")
    replyItem.Display

    ' comment out later
    ActiveInspector.CommandBars.ExecuteMso ("MessageOptions")

ExitRoutine:
    Set replyItem = Nothing

End Sub

Sub replyTo_test()
' First open a mailitem

Dim curritem As mailitem
Set curritem = ActiveInspector.currentItem

replyToExampleImmediately curritem
replyTosender curritem

End Sub

【讨论】:

    猜你喜欢
    • 2012-03-04
    • 2011-06-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-12-27
    • 1970-01-01
    相关资源
    最近更新 更多