login about faq

Hello,

I posted my question at the link http://www.groovypost.com/howto/microsoft/how-to-automatically-bcc-in-outlook-2010/ yesterday, but today that link is not working. What I want to do is slightly more complicated than what was posted at the link. Below is my original post.

What I am trying to do is create VBscript to CC or BCC (it doesn’t matter which) in the mailbox that I am sending from. I have a total of 5 mailboxes, including my personal and 4 shared boxes. I don’t want this applied to my personal or 1 of the shared, so I want to specify the mailbox names that it is being sent from. If it is one of the 3 it will place a copy of the email being sent into the inbox of the mailbox being sent from.

I know this can be easily done with creating rules, but we have shared mailboxes and due to how we log in, some people don’t like the rules and they uncheck them, very irritating. Also it appears there is no way to record a macro in Outlook, just create one.

I am trying to do something like this:


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

If From = "[email protected]" Then
    Forward.Recipients.Add "[email protected]"
End If

If From = "[email protected]" Then
    Forward.Recipients.Add "[email protected]"
End If

If From = "[email protected]" Then
    Forward.Recipients.Add "[email protected]"
End If

End Sub

I am not familiar with VBScript in Outlook at all, starting to get familiar with it in Excel though. Can someone please take a look at this and see if you know how to do this?

Thanks,

Chris

asked Feb 26 '13 at 07:59

zines's gravatar image

zines
5913514

edited Feb 26 '13 at 08:11


This will allow you to BCC in whatever mailboxes you specify. Notice the section where it has “If” statements that looks like this: If strEmailAccount = "[email protected]" Then strBcc = [email protected] There are 3 of these statements, just change the mailbox addresses to what you need. In my code below I have 3 mailboxes specified. If you only want 2 mailboxes, then delete an “If” statement, else if you want 4 mailboxes then add a statement. You can have as few or as many mailboxes you like. All you need to do is make an equivalent amount of “If” statements for each mailbox that you want to BCC.

This will also work when the email is first saved as draft. A lot of other codes will not work if the email was first opened from a draft, but this will. Please vote this answer up if it helps you.


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

Dim objRecip As Recipient
Dim res As Integer
Dim strBcc As String
Dim strMailCheck As String
Dim strEmailAccount As String

strMailCheck = "No"

If Item.SendUsingAccount Is Nothing Then
    strEmailAccount = Item.Parent.Parent
Else
    strEmailAccount = Item.SendUsingAccount
End If

If strEmailAccount = "[email protected]" Then
    strBcc = "[email protected]"
    strMailCheck = "Yes"
Else
   If strEmailAccount = "[email protected]" Then
        strBcc = "[email protected]"
        strMailCheck = "Yes"
    Else
        If strEmailAccount = "[email protected]" Then
            strBcc = "[email protected]"
            strMailCheck = "Yes"
        End If
    End If
End If

If strMailCheck = "Yes" Then
    Set objRecip = Item.Recipients.Add(strBcc)
    objRecip.Type = olBCC
    If Not objRecip.Resolve Then
        If res = vbNo Then
            Cancel = True
        End If
    End If
    Set objRecip = Nothing
End If

End Sub
link

answered Mar 20 '13 at 20:06

zines's gravatar image

zines
5913514

edited Jun 19 '13 at 20:21

Great find @zines -- thanks for the follow-up! +1

(Jun 21 '13 at 01:05) Steve Steve's gravatar image
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:
    [text](http://url.com/ "title")
  • image:
    ![alt text](/path/img.jpg "title")
  • numbered list:
    1. Foo
    2. Bar
  • Code:
    • Within a paragraph:
      `code`
      surround code with grave accents (backticks)
    • Code snippet:
      Select the text and use the button on the icon of zeros and ones
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×11

Asked: Feb 26 '13 at 07:59

Seen: 5,410 times

Last updated: Jun 21 '13 at 01:05

groovyAnswers © 2007 - 2011 All Rights Reserved | Privacy | Contact