Outlook security warning still displays

Add-in Express™ Support Service
That's what is more important than anything else

Outlook security warning still displays
 
grom grom




Posts: 55
Joined: 2008-05-21
I used your code sample. http://www.add-in-express.com/docs/outlook-security-manager-automate.php#samplecode

My Environment:

windows xp pro sp2
outlook 2002 sp1
vb.net 2005
security.manager 3.2.1812.2005

My Code:

Private Function SendMAPIEmail(ByVal sess As AxMSMAPI.AxMAPISession, ByVal msg As AxMSMAPI.AxMAPIMessages) As Boolean

' Purpose : Sends the e-mail using MAPI and return true on success
' Accepts : sess - reference to the MAPI session object
' msg - reference to the MAPI message object
' Returns : Boolean

Dim dtb As New DataTable
Dim intIndex As Integer

Try

DisableOutlookWarnings() ' :!: *************************** i disable outlook Security here *******************

ResolveMAPIRecipients(msg)

'Valide recipients
If SendTo.Trim = "" Then
SendTo = " "
End If

'Valide subjects
If Subject = "" Then
msg.MsgSubject = "(no subject)"
Else
msg.MsgSubject = Subject
End If

'Valide body
If Body = "" Then
msg.MsgNoteText = " "
Else
msg.MsgNoteText = Body
End If

ConvertStreamAttachments()

'Add attachments
intIndex = 0
For Each strFile As String In Attachments
msg.AttachmentIndex = intIndex
msg.AttachmentPosition = intIndex
msg.AttachmentType = MSMAPI.AttachTypeConstants.mapData
msg.AttachmentPathName = strFile
intIndex += 1
Next

'Send the e-mail
msg.Send()

ClearConvertedStreamAttachments()

Catch ex As Exception

Call HandleException(MethodBase.GetCurrentMethod(), ex)
Return False

Finally

Try

' Reset Outlook warnings
ResetOutlookWarnings() ' :!: *************************** i reset outlook Security here *******************

Catch ex As Exception

End Try

End Try

Return True

End Function

Private Sub ResolveMAPIRecipients(ByVal msg As AxMSMAPI.AxMAPIMessages)

' Purpose : Resolve the recipients against the MAPI Address Book
' Accepts : msg
' Returns : Nothing

Dim intCount As Integer
Dim strTo As String

If Me.SendTo.Trim = "" Then Exit Sub

Try

Try

While msg.RecipCount > 0
msg.RecipIndex = 0
msg.Delete(MSMAPI.DeleteConstants.mapRecipientDelete)
End While

Catch ex As Exception
End Try


If Me.SendTo.IndexOf(";") <> -1 Then
intCount = 0
Dim astrRecips() As String
Dim strRecip As String

astrRecips = Me.SendTo.Split(";")

For Each strRecip In astrRecips

strRecip = strRecip.Trim()

If strRecip <> "" Then

msg.RecipIndex = intCount

msg.RecipType = MSMAPI.RecipTypeConstants.mapToList
msg.RecipDisplayName = strRecip

msg.ResolveName()

intCount += 1

End If
Next

Else
msg.RecipIndex = 0
msg.RecipType = MSMAPI.RecipTypeConstants.mapToList
msg.RecipDisplayName = Me.SendTo
msg.ResolveName()
End If


Try

For intCount = 0 To msg.RecipCount - 1
msg.RecipIndex = intCount
strTo &= msg.RecipDisplayName & "; "
Next

Me.SendTo = strTo.Sub string(0, strTo.Length - 2)

Catch ex As Exception
End Try


Catch ex As Exception
End Try

End Sub

#Region "Outlook Security"

Private m_blnOriginalOutlookWarnings As Boolean
Private m_objSecurityManager As AddinExpress.Outlook.SecurityManager

Private Sub DisableOutlookWarnings()

' Purpose : Suppresses Outlook security warnings from displaying
' Accepts : Nothing
' Returns : Nothing

Dim objOutlookApplication As Outlook.Application
Dim objOutlookNameSpace As Outlook.NameSpace

objOutlookApplication = New Outlook.Application
objOutlookNameSpace = objOutlookApplication.GetNamespace("Mapi")
m_objSecurityManager = New AddinExpress.Outlook.SecurityManager

m_objSecurityManager.ConnectTo(objOutlookApplication)
m_blnOriginalOutlookWarnings = m_objSecurityManager.DisableOOMWarnings
m_objSecurityManager.DisableOOMWarnings = True

End Sub

Public Sub ResetOutlookWarnings()

' Purpose : Reset Outlook security warnings to the original value
' Accepts : Nothing
' Returns : Nothing

m_objSecurityManager.DisableOOMWarnings = m_blnOriginalOutlookWarnings

End Sub

#End Region
Posted 05 Jan, 2010 09:44:03 Top
Sergey Grischenko


Add-in Express team


Posts: 7202
Joined: 2004-07-05
Hi Grom.

You need to disable the security before you call any methods/properties of the Outlook Object model.
Please correct the code of the DisableOutlookWarnings method.
Posted 05 Jan, 2010 11:03:16 Top
grom grom




Posts: 55
Joined: 2008-05-21
Sergey,

I disable the messages before calling ResolveMAPIRecipients and msg.send as noted in my example. Am I missing something here?

Thanks,
Glenn
Posted 05 Jan, 2010 11:11:05 Top
Sergey Grischenko


Add-in Express team


Posts: 7202
Joined: 2004-07-05
Please replace the code below

objOutlookApplication = New Outlook.Application
objOutlookNameSpace = objOutlookApplication.GetNamespace("Mapi")
m_objSecurityManager = New AddinExpress.Outlook.SecurityManager
m_objSecurityManager.ConnectTo(objOutlookApplication)
m_blnOriginalOutlookWarnings = m_objSecurityManager.DisableOOMWarnings
m_objSecurityManager.DisableOOMWarnings = True

with the following

objOutlookApplication = New Outlook.Application
m_objSecurityManager = New AddinExpress.Outlook.SecurityManager
m_objSecurityManager.ConnectTo(objOutlookApplication)
m_blnOriginalOutlookWarnings = m_objSecurityManager.DisableOOMWarnings
m_objSecurityManager.DisableOOMWarnings = True
objOutlookNameSpace = objOutlookApplication.GetNamespace("Mapi")
Posted 05 Jan, 2010 11:16:56 Top
grom grom




Posts: 55
Joined: 2008-05-21
I replaced the code. Message still persists.
Posted 05 Jan, 2010 11:21:47 Top
Andrei Smolin


Add-in Express team


Posts: 14367
Joined: 2006-05-11
Hi Grom,

Try using DisableSMAPIWarnings instead of DisableOOMWarnings.

Regards from Belarus (GMT+2),

Andrei Smolin
Add-in Express Team Leader
Posted 06 Jan, 2010 10:48:32 Top
grom grom




Posts: 55
Joined: 2008-05-21
Thanks Andrei that worked!

All the best from Canada CST

Glenn
Posted 06 Jan, 2010 15:05:30 Top
Glenn r




Posts: 55
Joined: 2008-05-21
I'm getting another error now. Not sure if its related to the first. When I run the "m_objSecurityManager.ConnectTo(objOutlookApplication) " line it throws the exception "The ‘secman.OutlookSecurityManager’ COM object is not registered". This works from my dev machine but from a clinet machine it throws this exception.

objOutlookApplication = New Outlook.Application
m_objSecurityManager = New AddinExpress.Outlook.SecurityManager
m_objSecurityManager.ConnectTo(objOutlookApplication) '<-- exception thrown here*************************
m_blnOriginalOutlookWarnings = m_objSecurityManager.DisableSMAPIWarnings
m_objSecurityManager.DisableSMAPIWarnings = True
objOutlookNameSpace = objOutlookApplication.GetNamespace("Mapi")
Posted 08 Jan, 2010 16:35:09 Top
Andrei Smolin


Add-in Express team


Posts: 14367
Joined: 2006-05-11
Hi Glenn,

Try re-registering secman.dll.

Regards from Belarus (GMT+2),

Andrei Smolin
Add-in Express Team Leader
Posted 08 Jan, 2010 17:21:23 Top
Glenn r




Posts: 55
Joined: 2008-05-21
In my original program I did not explicitly register anything. The SecurityManager.2005.dll was in the same folder as the EXE. As per you advice I dragged and dropped the SecurityManager.2005.dll into the c:\windows\assembly folder. I even uninstalled and added it back a second time, rebooted. Still the same message "The ‘secman.OutlookSecurityManager’ COM object is not registered". Even though I'm not using it I also registerd the AddinExpress.OL.2005.dll in the GAC. Same message. Note I'm using windows xp pro sp2 and outlook 2002 sp3 on this machine.

This is the extent of my winforms test program:

references:
AddinExpress.OL.2005
Interop.Microsoft.Office.Core
Interop.Outlook
SecurityManager.2005
System
System.Data
System.Deployment
System.Drawing
System.Windows.Forms
System.Xml

Public Class Form1

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load


Try


DisableOutlookWarnings()

ResetOutlookWarnings()


Catch ex As Exception
MessageBox.Show(ex.Message)

End Try


End Sub

Private m_blnOriginalOutlookWarnings As Boolean
Private m_objSecurityManager As AddinExpress.Outlook.SecurityManager

Private Sub DisableOutlookWarnings()

' Purpose : Suppresses Outlook security warnings from displaying
' Accepts : Nothing
' Returns : Nothing

Dim objOutlookApplication As Outlook.Application
Dim objOutlookNameSpace As Outlook.NameSpace

MsgBox("1")

objOutlookApplication = New Outlook.Application
MsgBox("2")
objOutlookNameSpace = objOutlookApplication.GetNamespace("Mapi")
MsgBox("3")
m_objSecurityManager = New AddinExpress.Outlook.SecurityManager

MsgBox("4")

If objOutlookApplication Is Nothing Then
MsgBox("Nothing")
Else
MsgBox("not nothing")
End If
m_objSecurityManager.ConnectTo(objOutlookApplication)
MsgBox("5")
m_blnOriginalOutlookWarnings = m_objSecurityManager.DisableSMAPIWarnings
MsgBox("6")
m_objSecurityManager.DisableSMAPIWarnings = True

MsgBox("7")

End Sub

Public Sub ResetOutlookWarnings()

' Purpose : Reset Outlook security warnings to the original value
' Accepts : Nothing
' Returns : Nothing

m_objSecurityManager.DisableSMAPIWarnings = m_blnOriginalOutlookWarnings

End Sub

End Class
Posted 11 Jan, 2010 09:25:19 Top