Could not load file or assembly Interop.MAPI

  • Thread starter Thread starter Dhananjay
  • Start date Start date
D

Dhananjay

Hi All,
I am developing one VSTO addin for office 2007 in VB 2005. I have used
CDO. As per suggesion on MS site, I have given strong Name to my
addin. My addin is shown in the ol2007 perfectly, but when I tried to
open a custom form with clicking on my commandbar button, I am getting
the error as

"Could not load file or assembly Interop.MAPI, version = 1.21.0.0,
culture = nutral , publicKeytoken = ...... Or one of its dependancies.
Failed to grant permission to execute. ( Excception for HRESULT:
0x80131418)"

In my click event of the custom button, I have used some CDO
statements like
Try
Dim msg As MAPI.Message
Dim ses As New MAPI.Session
ses.Logon("", "", False, False)
msg = ses.GetMessage(myCurrentItem.EntryID)
If msg IsNot Nothing Then msg.Delete()
ses.Logoff()
msg = Nothing
ses = Nothing
Catch ex As System.Exception
AddTrace("Error while deleting mailitem - " & ex.Message)
End Try
Where am I wrong?

Thanks,
Dhananjay
 
CDO 1.21 is not installed by Outlook 2007.

Dmitry Streblechenko (MVP)http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool









- Show quoted text -

Thanks Dmitry for you reply,
So can't we use CDO 1.21 library from office 2003? Next, my code was
working perfectly when my project was in Shared Addin, but when I
changed the project to VSTO, I am facing those problems.
Further, I need to delete specific mail. I used above code snippet
for deleting the mail that I have currently opened. I used previously
myMail = Application.session.GetItemFromId(CurrentItem.EntryId)
for finding the currentItem, but it was giving me the value in myMail
as nothing.
So please can you tell me that how I can achieve the same effect in ol
model?

Thanks again
 
No, CDO 1.21 is not a standalone install in Outlook 2003.
Standalone version of MAPI includes CDO 1.21, but it will refuse to install
if you have a client (Outlook) version of MAPI already installed.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
To add to what Dmitry said, you can't redistribute CDO 1.21 and each version
is specific to a matched Outlook version. In addition, using CDO is not
supported at all for .NET code, so it might work or it might not or it might
work except at the client site and no one can help you.
 
Ken Slovak - said:
In addition, using
CDO is not supported at all for .NET code, so it might work or it
might not or it might work except at the client site and no one can
help you.

Ah, I think I hear my cue.. :)

KB article:

http://support.microsoft.com/kb/813349

More explanation:

http://blogs.msdn.com/mstehle/archive/2007/10/03/fyi-why-are-mapi-and-
cdo-1-21-not-supported-in-managed-net-code.aspx

Quote from MS support guy on the newsgroups about this:

"It's the sort of thing that'll mostly work. It'll work while you're
writing it. Then it'll work while you're testing it. It'll work while
your customer is evaluating it. Then as soon as the customer deploys it
- BAM! That's when it'll decide to start having problems. And Microsoft
ain't gonna help you with it, since we told you not to do it in the
first place. :)"

-- dan
 
Back
Top