Why can I save an attachment but not open it?

E

Eric

I've read all the previous posts about using the following methods to
add an attachment to a MAPI message from my COM add-in:

IMAPIFolder::CreateMessage()
IMessage::CreateAttach()
IAttach::SetProps() (set attachment method to 'by value')
IAttach::OpenProperty() to get the binary data property
Stream data to the property and save everything

All of this seems to work fine. When I open the email in Outlook I
can see the attachment, with the correct name ("Outlook1.bmp" in this
case), it has the correct icon, and also shows the correct file size.
If I double-click on the attachment Outlook says "The System Cannot
Find The Specified File". If I right-click on it and select "Save
As...", I can save it with no errors, and I can then open the file I
saved (with MSPaint in this case).

I assume Outlook is using some other property to try and create a temp
file so that I can open the file in MSPaint when I double-click it.
However, I've tried setting the PR_DISPLAY_NAME, PR_ATTACH_FILENAME,
PR_ATTACH_LONG_FILENAME, and even the PR_ATTACH_FILEPATH (which is not
supposed to be used for 'by value' attachments), and nothing has
worked...

Any ideas?
 
D

Dmitry Streblechenko \(MVP\)

If you add the same file using the Outlook UI and compare IAttach properties
using MdbView or OutlookSpy, do you see any differences?

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

Eric

The one I add with the Outlook UI has 24 properties, and mine only has
13. None of the missing 11 properties stand out as the one I really
need. I guess I could try them all, which wouldn't be too bad if I
had a utility to test adding/editing each property until I found the
correct combination. Whenever I edit the properties with Outlook Spy
I can't seem to get them to save, and when I tried the same thing with
mdbview I just get access violations (AVs and GPFs).

The properties which I'm missing and the values are:
PR_ACCESS_LEVEL = 1
PR_ATTACHMENT_FLAGS = 0
PR_ATTACHMENT_HIDEN = FALSE
PR_ATTACHMENT_LINKID = 0
PR_ATTACH_ENCODING = binary, cb = 0, lpb = NULL
PR_ATTACH_FLAGS = 0
PR_ATTACH_RENDERING = binary, cb = 3512, lpb = some data?
PR_CREATIONG_TIME = valid time/date
PR_EXCEPTION_ENDTIME = valid time/date
PR_EXCEPTION_STARTTIME = valid time/date
PR_LAST_MODIFICATION_TIME = valid time/date

Do any of those happen to ring a bell as to something which needs to
be set? I'll probably try the flags and access level first, since I
can't imagine any of those "time/date" values would be the problem. I
was just hoping someone might have added attachments to a message
before (I'm sure someone has) and already have a list of properties
that need to be set. Also, I don't want to find a combination that
works in 2002 (the version I happen to have installed on this system)
and then test on 2000 or 2003 and have to find a new combination
(although I realize this is what it takes sometimes).
 
E

Eric

Hmm.. I just got some new info, maybe this is actually a bug in
Outlook and has nothing to do with MAPI (so maybe I'll need to post in
a new newsgroup). If I add the same attachment (in my previous test
my code was adding a BMP file and via the UI I was testing with a TXT
file), now I get the error message even when I do the following steps
in Outlook:

Open a "new email" form. Select "insert file" and select a file named
"d:\eric\outlook1.bmp". Then I click "save" to save to the draft
folder. If I then try and double-click to open the attachment, I get
the same error message "The system cannot find the file specified".
However, if I do the same steps and add a TXT file as an attachment, I
don't get the error message. I also tried adding other BMP files and
I cannot open any of them, but I can open JPG files which both use the
same program when I open from Windows Explorer.

I'm thinking maybe Outlook just cannot find the program associated
with BMP files or something (not sure why?), so maybe I'm fighting
some bug or registry issue specific to my system, and not related to
the way I add attachments via MAPI.
 
F

fifty55

I finally solved the same problem. Exactly. I went to
assign file associations in (I think) folder options . I
assigned my jpg and bmps to open with windows viewer and
it now works fine.
Original Message-----
 

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