Attachment not display when add to mail

A

Ashish

I add an attachment to mail when open the mail in outlook. When i double
click on a mail then attachment display in mail.But when i right click on
mail select Open then i cant see the attachment while if i click on
File->Save Attachments then it shows me the attachment name. Which property
need to set to display the attachment
 
K

Ken Slovak - [MVP - Outlook]

Show the code you use. Are you saving the item after you add the attachment?
 
A

Ashish

No. I dont save the the item after adding attachment.
I add the attachment in Item_Open() eveny
item->Attachments->Add(filaname);
When i double click a mail attachment display in mail. WHen i right click
and select open then it's not display.
 
A

Ashish

I dont save item when i open it. But in my outlook addin when i open a item
and add an attachment in item_open many item events called like item_open,
item_write, item_read, item_attachmentadd,item_beforeattachmentsave etc
If i disable item_write( avoid writing) then it other events for this item
are stop. Should i disable item_write. But if i disable it then how to
enable other events.
 
K

Ken Slovak - [MVP - Outlook]

Don't disable the other events and try saving the item after you add the
attachment.
 
A

Ashish

I have tried to save item after adding attachment but it still dont display
attachment. I'm not saving item before adding attachment. I dont have much
knowledge for outlook addin. I think it is happening due to following
reason.

In my addin Open a mail from inbox folder(subject-> test1) add an attachment
in item_open event and save this mail(test1.msg type) on hard
disk(File->SaveAs) and close. Now Open test1.msg from hard disk(since
test1.msg is also in Inbox folder, item_open event call 2 times). After
closing this mail i found 2 mails of subject test1.msg in inbox folder. I am
handling all mail events throgh Inspector.

When i open a mail
register inspector event in a inspector class and pass
Application->CurrentInspector
In Notify of inspector class register mail event(outlook::Items)

Please suggest where i'm wrong
 
K

Ken Slovak - [MVP - Outlook]

Why are you saving the item as a MSG file and then re-opening it when you
already have that item saved in Outlook? What you are doing makes no sense
to me.
 
A

Ashish

I just tell this only for knowing the reason why attachment not display.
Ok If i dont save item as msg and reopen it then i still have the save
problem for attachment(right click on a item and select open).
 
K

Ken Slovak - [MVP - Outlook]

There should be no difference in how an item displays no matter how it's
opened.

You never did show any of your code, so no one knows what you are doing or
how.

Assuming you want to add an attachment when an item is opened then the way
I'd do it would be something like this, in the first Inspector.Activate()
event, assuming that _inspector is your Inspector object:

Outlook.MailItem mail = _inspector.CurrentItem;
Outlook.Attachments attachs = mail.Attachments;

Outlook.Attachment attach = attachs.Add(
"c:\foobar.jpg", (int)Outlook.OlAttachmentType.olByValue, 1,"My
Attachment Picture");

mail.Save();

// now release all those objects
 
A

Ashish

Thanks it's solved now. The problem was adding attachment in Item_Open
event. When i add attachment in Inspector.Activate() then it display.

I know how to use mail item event like item_open, item_close,item_fwd etc.
But i dont have idea how to implement context menu operations like when i
right click on any mail select any opertion like reply,forward etc. Are they
handled seperately
 
K

Ken Slovak - [MVP - Outlook]

What version of Outlook? For Outlook 2007 you have various new context menu
events on the Application object that you can handle and a shared event for
when a context menu closes. There are separate events for folder, item,
attachment, shortcuts, etc.

For earlier versions of Outlook there is nothing like that and you have to
use hacks that mostly work but don't tell you what was right-clicked or
where in the Outlook design surface. Examples of the hacks and various
problems that can arise are at http://www.outlookcode.com. Search there on
"context menu".
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top