ItemSend event fires twice?

B

Bingo

In the ItemSend event, I add an additional recipient as
BCC. But the event will fire again so the additional
recipient will be added again and the event just keeps
firing. Anything I'm doign wrong here? Thanks.
 
S

Sue Mosher [MVP-Outlook]

Show your code. You're not sending again are you? That's unnecessary.
 
B

Bingo

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

Dim oMapiRecipient As Outlook.Recipient
Dim oMapiItm As Outlook.MailItem
Dim sModName As String
Dim sMailbox As String

On Error GoTo errHandler

Set oMapiItm = Item
sModName = App.EXEName & ":" & CLASS_NAME
& ":ItemSendEvent"

WriteEvent sModName, "ItemSend Event Starts", LOG_INFO

' Only outgoing emails need to be copied to Claimbox
If Not oMapiItm.UserProperties("Direction") Is
Nothing And _
oMapiItm.UserProperties("Direction") = "O" Then
WriteEvent sModName, "Process an Outgoing
Message", LOG_INFO

If sMailbox <> "" Then
WriteEvent sModName, "Add Claimbox as BCC",
LOG_INFO
Set oMapiRecipient = oMapiItm.Recipients.Add
(oMapiItm.UserProperties("Claimbox"))
With oMapiRecipient
.Resolve
.Type = olBCC
End With
Else
' Cancel the process to keep the message
Cancel = True
WriteEvent sModName, "Missing Claimbox",
LOG_INFO
End If
End If

cleanUp:
Set oMapiRecipient = Nothing
Set oMapiItm = Nothing
Exit Sub
errHandler:
On Error Resume Next
WriteEvent sModName, "[" & Err.Number & "] " &
Err.Description, LOG_ERROR
GoTo cleanUp
End Sub
 

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