automatic BCC using Redemption

E

Ethan Shayne

I am trying to adopt the automatic BCC code shown on the Slipstick web
site (http://www.slipstick.com/dev/code/autobcc.htm) to work with the
Outlook Redemption library, as the Slipstick page suggests to get
around the security prompts.

Unfortunately, I don't seem to be able to get this to work.
Specifically, I tried substituting in the Redemption SafeMailItem
object (see VBA code below), but what seems to be happening is that
the Recipients.Add() method is returning Nothing (instead of the new
Recipient). Err is set to 13.

Has anyone successfully modified the Slipstick automatic BCC code to
work with Redemption? And if so, could you please post your script?
Or, failing that, can anyone tell me what I'm doing wrong?

Thanks,
Ethan

-------------------------

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As
Boolean)
Dim strMsg As String
Dim res As Integer
Dim strBcc As String
Dim oSafeItem As Object
Dim oRecip As Recipient

Set oSafeItem = CreateObject("Redemption.SafeMailItem")
oSafeItem.Item = Item

' #### USER OPTIONS ####
' address for Bcc -- must be SMTP address or resolvable
' to a name in the address book
strBcc = "(e-mail address removed)"

On Error Resume Next
Set oRecip = oSafeItem.Recipients.Add(strBcc)
If oRecip Is Nothing Then
strMsg = "BCC recipient could not be added (" & Err & "). Do
you still want to send the message?"
res = MsgBox(strMsg, vbYesNo + vbDefaultButton1, _
"Recipient could not be added")
If res = vbNo Then
Cancel = True
End If
End If

' 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
oRecip.Type = olBCC
oRecip.Resolve
If Not oRecip.Resolved Then
strMsg = "Could not resolve the Bcc recipient " & "(" &
Err & "). " & _
"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 oRecip = Nothing
Set oSafeItem = Nothing
End Sub
 
K

Ken Slovak - [MVP - Outlook]

You are declaring oRecip as a Recipient but SafeMailItem.Recipients
refers to Redemption SafeRecipients. That's why you are getting a type
mismatch error. Always use the Object Browser to see what type an item
should be, and to avoid confusion and possibly assigning a wrong item
type based on which reference library is listed first use fully
qualified declarations. For example, both Redemption and Outlook have
MAPIFolder objects. Depending on which library is listed first you
might get the wrong one if you don't fully qualify a declaration of
MAPIFolder.
 
E

Ethan Shayne

Thanks! That fixed it.

Thanks,
Ethan

Ken Slovak - said:
You are declaring oRecip as a Recipient but SafeMailItem.Recipients
refers to Redemption SafeRecipients. That's why you are getting a type
mismatch error. Always use the Object Browser to see what type an item
should be, and to avoid confusion and possibly assigning a wrong item
type based on which reference library is listed first use fully
qualified declarations. For example, both Redemption and Outlook have
MAPIFolder objects. Depending on which library is listed first you
might get the wrong one if you don't fully qualify a declaration of
MAPIFolder.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top