Consulting

Results 1 to 7 of 7

Thread: Auto BCC depends on Account

  1. #1

    Auto BCC depends on Account

    Hi All,

    i got the following Auto BCC script :

    [vba]
    Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
    Dim objRecip As Recipient
    Dim strMsg As String
    Dim res As Integer
    Dim strBcc as String
    ' #### USER OPTIONS ####
    ' address for Bcc -- must be SMTP address or resolvable
    ' to a name in the address book
    strBcc = "someone@somewhere.dom"
    On Error Resume Next
    Set objRecip = Item.Recipients.Add(strBcc)
    ' handle case of user canceling Outlook security dialog
    If Err = 287 Then
    strMsg = "Could not add a Bcc recipient " & _
    "because the user said No to the security prompt." & _
    " Do you want still to send the message?"
    res = MsgBox(strMsg, vbYesNo + vbDefaultButton1, _
    "Security Prompt Cancelled")
    If res = vbNo Then
    Cancel = True
    Else
    objRecip.Delete
    End If
    Err.Clear
    Else
    objRecip.Type = olBCC
    objRecip.Resolve
    If Not objRecip.Resolved Then
    strMsg = "Could not resolve the Bcc recipient. " & _
    "Do you want still to send the message?"
    res = MsgBox(strMsg, vbYesNo + vbDefaultButton1, _
    "Could Not Resolve Bcc Recipient")
    If res = vbNo Then
    Cancel = True
    End If
    End If
    End If
    Set objRecip = Nothing
    End Sub
    [/vba]

    As i have 2 email accounts( A and B), i just want to put BCC on email account A but do not let the AUTO BCC put enable on email account B.

    What's the field for FROM so that the script can verify if i'm using email account B, it will not append the BCC field.

    Appreciate your assistance on this.

    The above code is from http://www.outlookcode.com/d/code/autobcc.htm ( Method 2 )

    Edited 4-Aug-06 by geekgirlau. Reason: insert vba tags

  2. #2
    Moderator VBAX Master geekgirlau's Avatar
    Joined
    Aug 2004
    Location
    Melbourne, Australia
    Posts
    1,464
    Location
    Welcome to the Board!

    I don't have an answer for you, just a prompt to use the vba tags when you're posting code - it makes it much easier to read. To do this, highlight the code text, then click on the "VBA" button.

  3. #3
    Moderator VBAX Master Tommy's Avatar
    Joined
    May 2004
    Location
    Houston, TX
    Posts
    1,184
    Location
    [VBA]Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
    Dim objRecip As Recipient
    Dim strMsg As String
    Dim res As Integer
    Dim strBcc As String
    ' #### USER OPTIONS ####
    ' address for Bcc -- must be SMTP address or resolvable
    ' to a name in the address book
    '
    ' I change the code to the following. This should send a bcc only for user A
    '
    If Item.UserProperties.Session.CurrentUser.Address = "A" Then
    strBcc = "someone@somewhere.dom"
    On Error Resume Next
    Set objRecip = Item.Recipients.Add(strBcc)

    ' handle case of user canceling Outlook security dialog
    If Err = 287 Then
    strMsg = "Could not add a Bcc recipient " & _
    "because the user said No to the security prompt." & _
    " Do you want still to send the message?"
    res = MsgBox(strMsg, vbYesNo + vbDefaultButton1, _
    "Security Prompt Cancelled")
    If res = vbNo Then
    Cancel = True
    Else
    objRecip.Delete
    End If
    Err.Clear
    Else
    objRecip.Type = olBCC
    objRecip.Resolve
    If Not objRecip.Resolved Then
    strMsg = "Could not resolve the Bcc recipient. " & _
    "Do you want still to send the message?"
    res = MsgBox(strMsg, vbYesNo + vbDefaultButton1, _
    "Could Not Resolve Bcc Recipient")
    If res = vbNo Then
    Cancel = True
    End If
    End If
    End If
    Set objRecip = Nothing
    End If
    End Sub[/VBA]

  4. #4
    Hi Tommy,

    Thanks for reply.

    I've just tried it but it still add BCC to any of my mail account A or B.

    I'm using Outlook 2003. Is yours also the same version ?

  5. #5
    Moderator VBAX Master Tommy's Avatar
    Joined
    May 2004
    Location
    Houston, TX
    Posts
    1,184
    Location
    Yes I using 2003.
    Item.UserProperties.Session.CurrentUser.Address will hold the e-mail address is this what you are after?

  6. #6
    Quote Originally Posted by Tommy
    Yes I using 2003.
    Item.UserProperties.Session.CurrentUser.Address will hold the e-mail address is this what you are after?
    i have 2 email accounts to check emails. A is support@abc.com B is cklim@abc.com

    Whenever i reply email from support, i will use support@abc.com ( If i select this, ppl who received mail will see the mail is from support@abc.com ) , and i would send a blind carbon copy ( BCC ) to another of my colleagues who is also supporting on this email so he knows that i have replied the email.

    But i do not wish to BCC my personal mail to my colleagues ( which is cklim@abc.com when i reply to my fren or customer).

    Both email are have to be inside one outlook profile.

    So if i reply email using support@abc.com account.
    From: support@abc.com
    To: ( Any email address )
    BCC: colleagues@abc.com

    but if i reply email using cklim@abc.com account.
    From: cklim@abc.com
    To: ( any email address )
    BCC: NONE.

    I do not know the exact VB code that which one hold the email address of From Field so that i can do something to determine the From frield from VC code.

  7. #7
    Moderator VBAX Master Tommy's Avatar
    Joined
    May 2004
    Location
    Houston, TX
    Posts
    1,184
    Location
    change this:
    [vba] If Item.UserProperties.Session.CurrentUser.Address = "A" Then

    [/vba]
    to:
    [vba] If Item.UserProperties.Session.CurrentUser.Address = "support@abc.com" Then [/vba]
    I tested and it went through I got the e-mail twice, now testing for another e-mail address, looks like the bcc is not working

Posting Permissions

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