Log in

View Full Version : Solved: Adding BCC recipients



JohnnyBravo
05-13-2007, 12:07 PM
What I'm trying to do is automatically add "someone@msn.com" to the BCC field whenever I hit the reply button in Outlook. I was able to get some ideas through a Google search but for the some reason, the code does not activate when I hit 'Reply'. Can anyone offer some insight? I'm using office 2003 btw.


' Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean) I changed this line to:
Private Sub Application_ItemReply(ByVal Item As Object, Cancel As Boolean)

Dim objMe As Recipient
Set objMe = Item.Recipients.Add("someone@msn.com")
objMe.Type = olBCC
objMe.Resolve
Set objMe = Nothing
End Sub

geekgirlau
05-13-2007, 06:49 PM
It won't work because there is no "reply" event. What about the following:



Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim objMe As Recipient


If UCase(Left(Item.Subject, 3)) = "RE:" Then
Set objMe = Item.Recipients.Add("someone@msn.com")

objMe.Type = olBCC
objMe.Resolve
Set objMe = Nothing
End If
End Sub

JohnnyBravo
05-14-2007, 06:28 PM
I just tested out your code and it doesn't work Geekgirl.

geekgirlau
05-14-2007, 06:59 PM
Can you be a little more specific? What does "doesn't work" mean exactly?

JohnnyBravo
05-14-2007, 07:07 PM
I thought it was working but it's not.

It replies to the original sender, but I want to add a friend (We'll name him "Bob") in the 'BCC' field. I see that the reply gets sent but Bob's address does not appear in the BCC field and he's not getting copied on the BCC.

geekgirlau
05-14-2007, 07:33 PM
Have you tested to see that the event is being kicked off? Try adding a message box at the very beginning of the procedure, and check that you see the message when replying to a mail item.

JohnnyBravo
05-14-2007, 08:46 PM
OK did as you suggested and I did not see the message box.

Edit:

Well it finally worked. Your suggestion made me think about my security settings. I didn't stop to think that it may have been too high. After I set my security setting to 'Low' - the routine worked. Thanks for your help.

By the way, I see that you made the code dependent upon having the 'Re:' in the subject line. Is there no truly Reply event built into the VBA editor of Outlook so that the code could be activated simply when the user replies to the e-mail?

geekgirlau
05-14-2007, 08:57 PM
Okay, have a look at the Help in the VBE window for Outlook, and search for "Using events with Automation". Basically, the steps are as follows:

Set a reference to the Microsoft Outlook Object Library.
Declare an object variable to respond to the events.
Write the specific event procedures.
Initialize the declared object.See how you go with this, and let me know if you get stuck.

JohnnyBravo
05-14-2007, 09:17 PM
Ok, will do Geekgirl. This is actually a little favor I did for a friend of mine who heads up a social group in her neighborhood. I did it because I wanted to learn more about VBA, but right now I've got a few personal things I need to take care of.

I will have to revisit this soon though because I am very curious to see if I can improve my skills with this. I bought a book last year on VBA for Beginners but it really did not prove to be as helpful as I thought. :(

geekgirlau
05-14-2007, 09:40 PM
Automating Outlook directly is not an area I'm overly familiar with, but I have managed to get it running, and you should find the Help will get you through most of this.

However there are a couple of things to consider here. You are going to have to deal with Outlook security for one, and distribution of your code. This can be done by creating a COM add-in, but that sounds like overkill for your requirements. If it's just 1 person, I'd go with copying the code into her Outlook session directly.