[英]Outlook 2007 VBA Address Lists
I am trying to set the reply-to address of outbound emails based on whether a particular address is in the "To" or "CC" field of the outbound message.我正在尝试根据特定地址是否在出站邮件的“收件人”或“抄送”字段中来设置出站电子邮件的回复地址。 I have gotten this far, only to stumble on "Object required" errors on the "Set myCounter..." line.
我已经走到这一步,只是偶然发现了“Set myCounter ...”行上的“Object required”错误。 Any assistance would be greatly appreciated:
任何帮助将不胜感激:
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
Your error is on你的错误是
Set myCounter = oMyItem.Recipients.Count
because VB uses Set
to assign an object (a class), while you're getting an integer!因为 VB 使用
Set
分配一个 object (一个类),而你得到一个整数!
So you could change it into所以你可以把它改成
Dim myCounter As Integer
myCounter = oMyItem.Recipients.Count
myCounter
has been declared as an Integer so there is no need for the Set
. myCounter
已声明为 Integer,因此不需要Set
。
Replace代替
Set myCounter = oMyItem.Recipients.Count
with和
myCounter = oMyItem.Recipients.Count
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.