Consulting

Results 1 to 10 of 10

Thread: Solved: Adding BCC recipients

  1. #1

    Solved: Adding BCC recipients

    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.

    [vba]
    ' 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
    [/vba]

  2. #2
    Moderator VBAX Master geekgirlau's Avatar
    Joined
    Aug 2004
    Location
    Melbourne, Australia
    Posts
    1,464
    Location
    It won't work because there is no "reply" event. What about the following:

    [VBA]
    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
    [/VBA]

  3. #3
    I just tested out your code and it doesn't work Geekgirl.

  4. #4
    Moderator VBAX Master geekgirlau's Avatar
    Joined
    Aug 2004
    Location
    Melbourne, Australia
    Posts
    1,464
    Location
    Can you be a little more specific? What does "doesn't work" mean exactly?

  5. #5
    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.

  6. #6
    Moderator VBAX Master geekgirlau's Avatar
    Joined
    Aug 2004
    Location
    Melbourne, Australia
    Posts
    1,464
    Location
    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.

  7. #7
    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?
    Last edited by JohnnyBravo; 05-14-2007 at 09:00 PM.

  8. #8
    Moderator VBAX Master geekgirlau's Avatar
    Joined
    Aug 2004
    Location
    Melbourne, Australia
    Posts
    1,464
    Location
    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:
    1. Set a reference to the Microsoft Outlook Object Library.
    2. Declare an object variable to respond to the events.
    3. Write the specific event procedures.
    4. Initialize the declared object.
    See how you go with this, and let me know if you get stuck.

  9. #9
    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.

  10. #10
    Moderator VBAX Master geekgirlau's Avatar
    Joined
    Aug 2004
    Location
    Melbourne, Australia
    Posts
    1,464
    Location
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •