【发布时间】:2012-04-10 14:41:43
【问题描述】:
我正在尝试根据特定地址是在出站邮件的“收件人”还是“抄送”字段中设置出站电子邮件的回复地址。我已经走到这一步,只是在“Set myCounter ...”行中偶然发现“Object required”错误。任何帮助将不胜感激:
Option Explicit
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim oMyItem As Outlook.MailItem
Dim i As Integer
Dim AddressEntry As AddressEntry
Dim myCounter As Integer
Set oMyItem = Item
Set myCounter = oMyItem.Recipients.Count
For i = 1 To myCounter
Set AddressEntry = oMyItem.Recipients(i).AddressEntry
If (AddressEntry = "someuser@someaddress") Then
oMyItem.ReplyRecipients.Add "replytouser@someaddress"
End If
Next i
End Sub
【问题讨论】:
-
您是否检查过(使用调试器)
oMyItem和oMyItem.Recipients都不为空(无)? -
是的,我实际上已经解决了这个问题(当您的回复出现时),现在有一个单独的问题我可以轻松解决。对于那些感兴趣的人,我删除了声明 myCounter 的行并将 for 循环更改为: For i = 1 To oMyItem.Recipients.Count
标签: vba outlook outlook-2007