MAPI subsystem didn't initialize correctly

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

MAPI subsystem didn't initialize correctly
MAPIAccessor throws AddinExpress.MAPI.NotInitializedException  
Wolf-Guido Lutz




Posts: 6
Joined: 2010-12-14
Hello again,

I have found another thread in the forums with a download link for build 224 of the MAPI Store Accessor. With this component the initialization seems to run through correctly.

However, now the GetProperty doesn't work, it always returns NULL.

I have also tried the following code (AddinExpress.MAPI is in Imports):

Dim I As MapiItem = A.GetMapiItem(Item)
Dim B As Byte() = I.Attachments(Attachment).GetProperty(ADXMAPIPropertyTag._PR_ATTACH_DATA_BIN)

but I always gets set to Nothing after the first line.

Can you help me with this?

Thanks in advance,
Wolf-Guido Lutz

Dear Support,

I would like to access the MAPI Property PR_ATTACH_DATA_BIN in Outlook 2007 Attachments with the MAPI Store Accessor. I have downloaded version 23 build 222 from your website.

From your documentation I think this code should work (Item is an Outlook.MailItem):

Dim P As New AddinExpress.MAPI.ADXMAPIStoreAccessor
P.Initialize(False)

Dim B As Byte() = P.GetProperty(Item.Attachments(Attachment), CType(&H37010102, UInteger))
Dim F As New BinaryWriter(File.Create(AttachmentFileName))
F.Write(B)
F.Close()

However, in Line 2 (the call to Initialize) I get the error:

Exception Type: AddinExpress.MAPI.NotInitializedException
Exception Message: MAPI subsystem didn't initialize correctly

I think this has to do with my not using the Add-In Express Add-In. I would like to keep the code as simple as possible. In article:

http://www.add-in-express.com/forum/read.php?FID=5&TID=7456&MID=37382#message37382

there seems to be a hotfix for this. However, I don't know if this also applies to the MAPI Store Accessor? If so, could I get this update too?

Thanks in advance,
Wolf-Guido Lutz
Posted 14 Dec, 2010 04:17:05 Top
Eugene Astafiev


Guest


Hi Wolf-Guido,

You don't need to use the 224th build of the MAPI Store Accessor. Instead, I have noticed that you pass false to the Initialize method:

P.Initialize(False)


As far as I know you don't use it in the add-in project. Am I right? If so, please try to pass true instead. Does it help?
Posted 14 Dec, 2010 07:17:29 Top
Wolf-Guido Lutz




Posts: 6
Joined: 2010-12-14
Hello Eugene,

I'm afraid not. I already tried that, and I get the same error. Apart from that, there is a reference to a MailItem in the current session that I would need in order to get to its attachments.

Outlook is definetly open at that point. I am trying to read the embedded images from the item that the user just created, and my code is in the Item_Send event.

You are right, I am using the Accessor in a Windows Forms application. But do you think the newer build doesn't really help here? At least this error seems to go away with it.

With regards,
Wolf-Guido Lutz
Posted 14 Dec, 2010 08:17:59 Top
Eugene Astafiev


Guest


Hi Wolf-Guido,

In that case it makes sense to use the last build of the MAPI Store Accessor. Did you try to use the MAPI Store Accessor component in any other place except the Item_Send event handler? It looks like the ItemSend event handler is the cause of the issue. Also please make sure that all Outlook objects have the EntryID property set.
Posted 14 Dec, 2010 08:41:55 Top
Wolf-Guido Lutz




Posts: 6
Joined: 2010-12-14
Hi Eugene,

Thanks, but still negative. I have tried the code outside the Item_Send event and it doesn't work either. However, I don't quite understand the issue with the Entry IDs. The EntryID of the MailItem is in fact not set, but it won't get set because I don't need to save the Item.

Does this mean that I can't use the Accessor because the MailItem isn't saved to the store?

Thanks for your advice,
Wolf-Guido Lutz
Posted 14 Dec, 2010 09:16:31 Top
Eugene Astafiev


Guest


Hi Wolf-Guido,

Yes, it does. Please try saving your mail item first.
Posted 14 Dec, 2010 09:19:37 Top
Wolf-Guido Lutz




Posts: 6
Joined: 2010-12-14
Hi Eugene,

ok, I did this. Now the call

Dim I As MapiItem = A.GetMapiItem(Item)

works, but the attachment count of the resulting I is 0. So I can't access the attachment. On the other hand, if I try to read the property directly from the outlook attachment object

Dim B As Byte() = P.GetProperty(Item.Attachments(Attachment), ADXMAPIPropertyTag._PR_ATTACH_DATA_BIN)

this still gives NULL. Is there some problem specifically with attachments that I am overlooking?

Thanks in advance,
Wolf-Guido Lutz
Posted 14 Dec, 2010 09:35:06 Top
Wolf-Guido Lutz




Posts: 6
Joined: 2010-12-14
Hi Eugene,

Thanks for your help, I have finally solved the problem, your hints have got me on the way. I just want to share this with you for future requests.

The problem of not being able to access the inline image attachments in an outlook message persists only as long as the message isn't saved to the default folder. After that, all one has to do is to use the Method SaveAsFile from the attachment object in outlook.

Which in a way sadly means that I now don't need the control anymore, but there are still lots of other situations for that. And I am really thankful for your help, it it weren't for you I'd never have found a solution...

With regards,
Wolf-Guido Lutz
Posted 15 Dec, 2010 01:36:53 Top
Eugene Astafiev


Guest


You are welcome, Wolf-Guido!
Posted 15 Dec, 2010 04:59:58 Top