A
Adam
Hey Guys,
Here's the scenario, I am writing an outlook add-in that will
cross-reference all of the recipients of an email against a user defined
data source to see if the contact is a corporate contact. If one of the
recipients is in the corporate contacts list then it adds an email address
to the BCC field of the MailItem object.
I actually have 2 problems here.
1) Every time I run this process outlook stops everything
and alerts me that some application is trying to access my contacts list and
if want I can allow it for 1,2,3,4 or 10 minutes. This is unacceptable due
to business specifications so I need to find a workaround for this.
2) When I try to add the email address to the BCC field
none of my error handling fires but outlook pops up with a nice little
message saying "operation failed" . gotta love the descriptive error message
... This happens where ever I try to do this. The thing is that after I get
that message It leaves the message open and I can see the email address I
tried to add in the BCC field so I'm not exactly sure what part fails but
I'm
at my wits end
Here's the code:
'OMF is a class I built that actually does all the processing
'The ItemSend Event:
Public Sub applicationObject_ItemSend(ByVal Item As Object, ByRef Cancel
As Boolean) Handles applicationObject.ItemSend
Dim str As String
str = OMF.Send(Item, applicationObject)
Item.BCC = str
End Sub
'The OMF.Send Function
'the isContact works fine and Me.Email is a property holding the email
address to add to the BCC field
'oA is a global Outlook Application
Public Function Send(ByRef mail As Outlook.MailItem, ByRef app As
Outlook.Application) As String
'variables
oA = app
Trace = 1
Dim ret As String = "none"
Dim strTo As String()
Dim strRead As String
Trace = 2
Try
strTo = mail.To.Split(emailTokens)
Trace = 3
For Each rep As String In strTo
Trace = 4
If isContact(rep) Then
Trace = 15
If Not IsNothing(mail.BCC) Then
Trace = 155
If InStr(mail.BCC.ToString, ";") Then
Trace = 16
ret = Me.Email
Else
Trace = 17
ret = Me.Email
End If
Else
ret = Me.Email
End If
End If
Next
Catch ex As SystemException
MessageBox.Show("Trace " & Trace & vbNewLine & "Error: " &
vbNewLine & ex.Message & vbNewLine & "Stack Trace:" & vbNewLine &
ex.StackTrace)
writeError(ex)
End Try
Return ret
End Function
This needs to be compatible with Outlook / Exchange 2000 +
Any help or input would be greatly appreciated guys
TIA
- Adam
Here's the scenario, I am writing an outlook add-in that will
cross-reference all of the recipients of an email against a user defined
data source to see if the contact is a corporate contact. If one of the
recipients is in the corporate contacts list then it adds an email address
to the BCC field of the MailItem object.
I actually have 2 problems here.
1) Every time I run this process outlook stops everything
and alerts me that some application is trying to access my contacts list and
if want I can allow it for 1,2,3,4 or 10 minutes. This is unacceptable due
to business specifications so I need to find a workaround for this.
2) When I try to add the email address to the BCC field
none of my error handling fires but outlook pops up with a nice little
message saying "operation failed" . gotta love the descriptive error message
... This happens where ever I try to do this. The thing is that after I get
that message It leaves the message open and I can see the email address I
tried to add in the BCC field so I'm not exactly sure what part fails but
I'm
at my wits end
Here's the code:
'OMF is a class I built that actually does all the processing
'The ItemSend Event:
Public Sub applicationObject_ItemSend(ByVal Item As Object, ByRef Cancel
As Boolean) Handles applicationObject.ItemSend
Dim str As String
str = OMF.Send(Item, applicationObject)
Item.BCC = str
End Sub
'The OMF.Send Function
'the isContact works fine and Me.Email is a property holding the email
address to add to the BCC field
'oA is a global Outlook Application
Public Function Send(ByRef mail As Outlook.MailItem, ByRef app As
Outlook.Application) As String
'variables
oA = app
Trace = 1
Dim ret As String = "none"
Dim strTo As String()
Dim strRead As String
Trace = 2
Try
strTo = mail.To.Split(emailTokens)
Trace = 3
For Each rep As String In strTo
Trace = 4
If isContact(rep) Then
Trace = 15
If Not IsNothing(mail.BCC) Then
Trace = 155
If InStr(mail.BCC.ToString, ";") Then
Trace = 16
ret = Me.Email
Else
Trace = 17
ret = Me.Email
End If
Else
ret = Me.Email
End If
End If
Next
Catch ex As SystemException
MessageBox.Show("Trace " & Trace & vbNewLine & "Error: " &
vbNewLine & ex.Message & vbNewLine & "Stack Trace:" & vbNewLine &
ex.StackTrace)
writeError(ex)
End Try
Return ret
End Function
This needs to be compatible with Outlook / Exchange 2000 +
Any help or input would be greatly appreciated guys
TIA
- Adam