-1

我正在尝试根据特定地址是在出站邮件的“收件人”还是“抄送”字段中设置出站电子邮件的回复地址。我已经走到这一步,只是在“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
4

2 回答 2

0

你的错误是

Set myCounter = oMyItem.Recipients.Count

因为VB用来Set分配一个对象(一个类),而你得到一个整数!
所以你可以把它改成

Dim myCounter As Integer

myCounter = oMyItem.Recipients.Count
于 2012-04-10T14:43:15.223 回答
0

myCounter已被声明为整数,因此不需要Set.

代替

Set myCounter = oMyItem.Recipients.Count 

myCounter = oMyItem.Recipients.Count
于 2012-04-10T14:55:50.297 回答