Log in

View Full Version : Auto BCC depends on Account



mcking
08-03-2006, 10:25 AM
Hi All,

i got the following Auto BCC script :


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


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

geekgirlau
08-04-2006, 12:57 AM
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.

Tommy
08-05-2006, 11:50 AM
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

mcking
08-05-2006, 11:20 PM
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 ?

Tommy
08-06-2006, 07:02 AM
Yes I using 2003.
Item.UserProperties.Session.CurrentUser.Address will hold the e-mail address is this what you are after?

mcking
08-06-2006, 07:15 AM
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.

Tommy
08-06-2006, 08:09 AM
change this:
If Item.UserProperties.Session.CurrentUser.Address = "A" Then


to:
If Item.UserProperties.Session.CurrentUser.Address = "support@abc.com" Then
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