"Member not found" exception OnItemSend event when trying to save item

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

"Member not found" exception OnItemSend event when trying to save item
 
Denis Pivnenko




Posts: 4
Joined: 2011-11-11
Hello Add-in Express team,
I have the problem/error when try to save a mail item on Item Send event, in case if mail was forwarded and has inline/embedded attachments (images in mail body/signature) in Outlook 2010 x32 SP1.

So, how it reproduces - someone forward to me a mail, for example, with attached Word document and with image in mail body (signature with an image), then I forward it too, write some comments and click send- OnItemSend event triggers in my add-in. On this event I cancel sending (logic of my add-in in specific cases). Then I click send button again and get following error: "Member not found" on mailItem.Save(). If forwarded to me mail does not have images in mail body then mail send without errors.

Code example:

procedure TAddInModule.adxOutlookAppEvents1ItemSend(ASender: TObject;
  const Item: IDispatch; var Cancel: WordBool);
Var mail: MailItem;   
begin
  mail := (Item as MailItem);
  try
    mail.Save; // error "Member not found" is here
  finally
    mail := nil;
    Cancel := true;
  end;
end;



In this this topic Andrei Smolin mentioned that the problem can be caused by embedded pictures:
Is that error reproducible for some special email? Does that email contain embedded pictures? Is the issue reproducible if you remove the pictures?
Andrei Smolin
Add-in Express Team Leader


So, could someone from the Add-in Express team help me and provide me with information or link to MS KB or discussions about such problem or some workaround?

Which MAPI properties of mail can be affected by embedded images in mail body?


Thanks in advance.
Add-in Express for VCL/ Add-in Express for .Net
Posted 09 Nov, 2012 11:32:24 Top
Andrei Smolin


Add-in Express team


Posts: 14115
Joined: 2006-05-11
Hi Denis,

I cannot reproduce the issue. I've found however that this error message occurs when you deal with attachments. Supposedly this requires certain environment and also attachments of certain types. Here are some of the pages I found:

- http://social.msdn.microsoft.com/Forums/en-US/outlookdev/thread/438b734a-2278-46f5-9e7d-b16e9bf66d2d/
- http://social.msdn.microsoft.com/Forums/en-US/outlookdev/thread/82ec78c5-41ac-453d-875d-7c51437486d7/
- http://stackoverflow.com/questions/11304754/attach-binary-data-to-email-attachment
- http://go4answers.webhost4life.com/Example/copy-attachments-169402.aspx

Do you manipulate attachments in your code? BTW, are we talking about a COM add-in or a standalone application? Is it Exchange or PST?

Can you rewrite your code so that Mail.Save is called only if Cancel is false?

Regards from Belarus (GMT+2),

Andrei Smolin
Add-in Express Team Leader
Posted 13 Nov, 2012 06:31:21 Top
Denis Pivnenko




Posts: 4
Joined: 2011-11-11

Thanks for the links, will check and investigate.

Do you manipulate attachments in your code?

No, I don't. The only event which handled in my test add-in is OnItemSend event with code:

procedure TAddInModule.adxOutlookAppEvents1ItemSend(ASender: TObject;
  const Item: IDispatch; var Cancel: WordBool);
begin
  try
    if not Cancel then
     (Item as mailitem).Save();
  finally
    Cancel := true;
  end;
end;



BTW, are we talking about a COM add-in or a standalone application?

We are talking about test COM add-in compiled with Delphi + Add-in Express for VCL v702-b1212

Is it Exchange or PST?

Uses Exchange server.

Can you rewrite your code so that Mail.Save is called only if Cancel is false?

Rewrote. Does not help (the same behavior).

The interesting thing that the problem reproduces only when a mail body has embedded attachments (images in mail body) and has at least one regular attachment (Word doc for example). If no images or no regular attachments all going ok.


I cannot reproduce the issue

:(
On my side it reproduces on second click on "Send" button - first execution of OnItemSend is ok, second is going with "Member not found" exception on mail save.

My environment:
- Win7 x64;
- Office 2010 x32 SP1.


With best regards from Chernigov, Ukraine (GMT+2),
Denis Pivnenko.
Add-in Express for VCL/ Add-in Express for .Net
Posted 13 Nov, 2012 08:31:07 Top
Andrei Smolin


Add-in Express team


Posts: 14115
Joined: 2006-05-11
I don't know how to solve this. Currently this looks like some configuration problem in your Exchange/Outlook. Can you please send me an email with a test email attached to it?

Regards from Belarus (GMT+2),

Andrei Smolin
Add-in Express Team Leader
Posted 13 Nov, 2012 10:48:53 Top
Denis Pivnenko




Posts: 4
Joined: 2011-11-11
The links that you provide me with are about similar problem, but not about mine (unfortunately).
Currently this looks like some configuration problem in your Exchange/Outlook

Yes, seems it does.

Can you please send me an email with a test email attached to it?

I have sent you mail to Add-in Express support email address.

With best regards from Chernigov, Ukraine (GMT+2),
Denis Pivnenko.
Add-in Express for VCL/ Add-in Express for .Net
Posted 13 Nov, 2012 11:34:00 Top
Dmitry Kostochko


Add-in Express team


Posts: 2731
Joined: 2004-04-05
Hi Denis,

I cannot reproduce the issue even with the email samples you sent. Could you please try to test the following code on your side:

procedure TAddInModule.adxOutlookAppEvents1ItemSend(ASender: TObject;
  const Item: IDispatch; var Cancel: WordBool);
var
  Mail: _MailItem;
begin
  try
    if not Cancel then begin
      Item.QueryInterface(IID__MailItem, Mail);
      if Assigned(Mail) then
        try
          Mail.Save();
        finally
          Mail := nil;
        end;
    end;
  finally
    Cancel := True;
  end;
end;
Posted 16 Nov, 2012 03:09:41 Top
Denis Pivnenko




Posts: 4
Joined: 2011-11-11
Thanks, Dmitry,
I have tried and have the same results.
Moreover I have the same results even I execute the same code on VBA.
I tried to delete account .ost file on my side and on mail sender's side and then after Outlook synchronization (with Exchange server) I still have that exception.
So, it looks like mail items corrupted on Exchange server side. And I cannot do anything in my code to fix the problem.

Anyway, thanks a lot for the help, I appreciate it.
The topic can be closed.

With best regards from Chernigov, Ukraine (GMT+2),
Denis Pivnenko.
Add-in Express for VCL/ Add-in Express for .Net
Posted 19 Nov, 2012 10:32:46 Top