Getting Error Member not found. (Exception from HRESULT: 0x80020003 (DISP_E_MEMBERNOTFOUND))

0

I am developing Outlook 2013 Addin.

My scenario:

  1. Get email data of selected email from outlook mail window

  2. Create new email item

  3. Update new email item with the email data from selected email

  4. send email

If i am selecting email without attachments and do the operation , then it is working fine.

But if selected email has attachments, then i am getting error Member not found. (Exception from HRESULT: 0x80020003 (DISP_E_MEMBERNOTFOUND))

To get Selected email data, i am using below code

MailItem mailItem = null;
Attachments mtAttachments = null;

Explorer explorer = Globals.ThisAddIn.Application.ActiveExplorer();

if (explorer != null && explorer.Selection != null && explorer.Selection.Count > 0)
            {
                object item = explorer.Selection[1];
                if (item is MailItem)
                {
                    mailItem = item as MailItem;
                    subject = mailItem.Subject;
                    body = mailItem.HTMLBody;
                    mtAttachments = mailItem.Attachments;
                }
            }    

To Send new email with attachments i am using below code.

enter image description here

And i am getting below Error .

enter image description here

Can any one please help me.?

outlook
outlook-addin
outlook-2013
asked on Stack Overflow Nov 11, 2014 by User5590

1 Answer

1

Attachments.Add can only take a string with the file name or another Outlook item (MailItem, XContactItem, etc.). It does not take an instance of Attachments object as an argument.

If you want to copy attachments from one message to another, save then as files first, then pass the attachment file name as the parameter.


User contributions licensed under CC BY-SA 3.0