Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

hide attachment using extended mapi

16 views
Skip to first unread message

Ashish

unread,
Sep 3, 2009, 2:57:56 AM9/3/09
to
In my outlook addin i'm trying to hide attachment for a mail in active
explorer when this mail is select using following code

Suppose mail has one attachment

LPMESSAGE lpMessage = (IMessage*)(IUnknown*)
mailitem->Attachments->Item(1)->MAPIOBJECT;

SPropValue pProp;
pProp.ulPropTag = PR_ATTACHMENT_HIDDEN;
pProp.Value.b = true;

HRESULT hr = HrSetOneProp(lpMessage, &pProp);
if(hr == S_OK)
lpMessage->SaveChanges(FORCE_SAVE);

Also i have tried to change other properties like PR_ATTACH_METHOD,
PR_ATTACH_FILE_NAME etc. but nothing happed. I have tried not to use
SaveChanges method but no result.


SvenC

unread,
Sep 3, 2009, 3:30:16 AM9/3/09
to
Hi Ashish,

> In my outlook addin i'm trying to hide attachment for a mail in active
> explorer when this mail is select using following code
>
> Suppose mail has one attachment
>
> LPMESSAGE lpMessage = (IMessage*)(IUnknown*)
> mailitem->Attachments->Item(1)->MAPIOBJECT;

IIRC you cannot hide a single attachment in a mail but only
tell a mail to hide all its attachments.

So try to use:

LPMESSAGE lpMessage = (IMessage*)(IUnknown*)
mailitem->MAPIOBJECT;

(btw: your code looks like you are leaking MAPIOBJECT)

followed by your code.

--
SvenC

Ashish

unread,
Sep 3, 2009, 5:36:02 AM9/3/09
to
Hi SyenC,
Thanks for your response.
If i use MAPIOBJECT of mail item then which property i need to reset. I
think i cant not access PR_ATTACHMENT_HIDDEN through mail item mapi object.
I have tried to use PR_ATTR_HIDDEN through redemption outspy but attachment
still display in right pane.
"SvenC" <Sv...@nospam.nospam> wrote in message
news:%239JxhhG...@TK2MSFTNGP04.phx.gbl...

SvenC

unread,
Sep 3, 2009, 8:30:31 AM9/3/09
to
Hi Ashish,

> Thanks for your response.
> If i use MAPIOBJECT of mail item then which property i need to reset. I
> think i cant not access PR_ATTACHMENT_HIDDEN through mail item mapi object.
> I have tried to use PR_ATTR_HIDDEN through redemption outspy but attachment
> still display in right pane.

Sorry, i remembered incorrectly. PR_ATTACHMENT_HIDDEN on the attachment
is the correct way to go. But you will need to get an IMAPIProp (or IAttach) of
the attachment and an IMAPIProp (or IMessage) of the mail and after setting the
property on the attachment you need to call SaveChanges on the attachment
and on the mail interface.

To make the attachment icon on the mail disappear you need to set
PR_HIDE_ATTACH to true which is a named property with this DASL
http://schemas.microsoft.com/mapi/id/{00062008-0000-0000-C000-000000000046}/8514000B

So it is a boolean with the MAPINAMEID id 0x8514

--
SvenC

Ashish

unread,
Sep 3, 2009, 9:22:33 AM9/3/09
to
Thanks. Now attachment is hide. But it's not reflect immediately in right. I
need to select different mail and go back to previous mail. Is there any
function to refresh right pane?


Can we hide attachment on exchange server using CDO also?
I tried to do it like

Suppose a mail has one attachment, i open this mail using IDataSource->Open
and access this using CDO::IMessage. When i check that mail in outlook it
still has attachment.

CDO::IMessage Msg;

FieldsPtr Flds;

IBodyPartPtr bodypart = Msg->Attachments->Item[i];

Flds = bodypart->Fields;

try

{

Fldsat->Item[
"http://schemas.microsoft.com/mapi/proptag/0x7FFE000B" ]->Value

= _variant_t( "1" );

Fldsat->Update();

Fldsat = NULL;

}

catch(...)

{

}


"SvenC" <Sv...@nospam.nospam> wrote in message

news:uNWxVJJL...@TK2MSFTNGP04.phx.gbl...

Ashish

unread,
Sep 3, 2009, 10:10:27 AM9/3/09
to
If i call SaveChanges(FORCE_SAVE) then it updates mail last modified date.
Can we hide icon without changing mail last modified date.
Using CDO::IMessage, CDO::IBodyPart i am not able to hide icon. Is it
possible? Is there any example

"SvenC" <Sv...@nospam.nospam> wrote in message
news:uNWxVJJL...@TK2MSFTNGP04.phx.gbl...

SvenC

unread,
Sep 3, 2009, 12:59:15 PM9/3/09
to
Hi Ashish,

> If i call SaveChanges(FORCE_SAVE) then it updates mail last modified date.
> Can we hide icon without changing mail last modified date.

I doubt it.

> Using CDO::IMessage, CDO::IBodyPart i am not able to hide icon. Is it
> possible? Is there any example

Never used that version of CDO except for very basic mailing tasks.
So, I don't know.

--
SvenC

Ashish

unread,
Sep 4, 2009, 9:03:39 AM9/4/09
to
Do you mean SaveChanges(FORCE_SAVE) should not update any date of the mail

"SvenC" <Sv...@nospam.nospam> wrote in message
news:ujS0efLL...@TK2MSFTNGP05.phx.gbl...

Dmitry Streblechenko

unread,
Sep 4, 2009, 12:41:22 PM9/4/09
to
No matter what flags you use, saving a message wil update its last modified
date.

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"Ashish" <akohl...@hotmail.com> wrote in message
news:u8eTTBWL...@TK2MSFTNGP05.phx.gbl...

SvenC

unread,
Sep 4, 2009, 1:22:31 PM9/4/09
to
Hi Ashish,

>>> If i call SaveChanges(FORCE_SAVE) then it updates mail last modified
>>> date. Can we hide icon without changing mail last modified date.
>>
>> I doubt it.
>

> Do you mean SaveChanges(FORCE_SAVE) should not update any date of the mail

No. I was answering your last sentence "Can we hide icon without changing mail
last modified date." And my answer to that question was "I doubt it".

Otherwise, Dmitry has brought it to the point in his answer.

--
SvenC

varun

unread,
Sep 4, 2009, 3:53:49 PM9/4/09
to
Thanks all
so if we call savechanges then it'll change last modified date and we cant
hide attachments without saving.

When we hide attachments in active explorer when select a mail, it's not
reflected immediately in right pane. we need to select another item then go
back to original item to see attachments are hide. Can we reflect right pane
immediately when select a mail. Is there any refresh method or something
else?


"Ashish" <akohl...@hotmail.com> wrote in message
news:u8eTTBWL...@TK2MSFTNGP05.phx.gbl...

Dmitry Streblechenko

unread,
Sep 4, 2009, 4:01:22 PM9/4/09
to
No, if Outlook decides to cache something, it is hard to make it forget it.

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

"varun" <varun....@yahoo.co.in> wrote in message
news:OuhYvlZL...@TK2MSFTNGP03.phx.gbl...

0 new messages