Active explorer issue

A

Ashish

In Active inspector when open a mail, If add an attachment to a mail and
dont call Save function then this attachment will not update on exchange
server for this mail.

But In active explorer when select a mail we add attachment to a mail and
dont save save function. Attachment is updated on exchange server for this
mail. Is there any reason for that? Can we avoid saving? Outlook
version-2003
 
K

Ken Slovak - [MVP - Outlook]

How are you adding an attachment in ActiveExplorer()? Is it with code or
from the UI. If using code show it.

In general you always have to save, possibly unless in-cell editing is
enabled and that affects automatically saving any changes. See if the Saved
property on the item has changed after you add the attachment in the
Explorer.
 
A

Ashish

I'm adding attachment in code under explorer_viewchange event(when selecta
mail item). When i add attachment to a mail in ActiveExplorer->ViewChange
event, mail item save property returns false. But when i select another mail
item item and check Save property of previous mail item where i add
attachment then it returns true. It means that attachment is added on
exchange server.
How to use in-cell editing ?? Can we avoid saving if we add an attachment.
My user is exchange server user and has cached mode on.

//in c++ event number is 0xf007

Outlook::_MailItemPtr pMailItem = NULL;
Explorer_ViewChange()
{
if(pMailItem != NULL)//if we select an item before and already add
attachment to it
{
bool issaved = pMailItem->GetSaved(); //GetSaved return true
}
else
{
Outlook::SelectionPtr spSelections = ActiveExplorer->Selection;
if( spSelections)
{
int selecteditems = spSelections->Count;
if(selecteditems == 1)
{
pMailItem = spSelections->Item(1);
pMailItem ->Attachments->Add("c:/filename.txt");
bool issaved = pMailItem->GetSaved(); //GetSaved
return false
}//here i dont call pMailItem->save function
}
}
}
 
K

Ken Slovak - [MVP - Outlook]

Do you mean the ViewSwitch() event? There is no ViewChange() event. Why
aren't you using Explorer.SelectionChange(), that would be the correct event
to handle.
 
A

Ashish

Sorry it's explorer.selectionchange
it's call when i change selection on any mail/folder
 
K

Ken Slovak - [MVP - Outlook]

If you want to know whether or not an item in a Selection is changed you
handle SelectionChange(). When that fires you get the new Selection. You can
then set up handlers for each item in the Selection and handle the
AttachmentAdd() event or the BeforeAttachmentSave() event or any other
attachment related event you want to track.
 
A

Ashish

So if i handle those attachment events and avoid saving then it will not
update on exchange server. But will it allow to add attachment to mail and
display in outlook when we select a mail?
 
A

Ashish

i tried it but attachment still save on exchange server. I handle
beforeattachmentsave and addattachment and cancel the saving but attachment
still save on exchange server. I follow below link to avoid saving
http://codeidol.com/csharp/c-sharp-in-office/Working-with-Outlook-Events/Outlook-Item-Events/


To avoid saving when i select another mail i delete attachments from
previous mail and call save function. But this modify mail date. I want to
add attachment in mail without modifying its date.
 
K

Ken Slovak - [MVP - Outlook]

I'm afraid what you want can't be done. If you modify an item it will get
some date related fields also modified. Not much you can do about that.
 
A

Ashish

To modify item i'm only adding attachment for a selected item in outlook
explorer. And when select another item i delete attachment from previous
item where i add. All this i'm doing without saving item. But this action
save item on exchange server. But we can avoid this saving as below link
says that
http://codeidol.com/csharp/c-sharp-in-office/Working-with-Outlook-Events/Outlook-Item-Events/

My motive is to display attachments when select a item and delete them when
select another item. And this all should not modify on exchange server.
It it not possible?
 
K

Ken Slovak - [MVP - Outlook]

I don't think what you want is possible, no. Not using the Outlook object
model anyway.
 
A

Ashish

oh. It means i need to change my design again. To complete my task there is
one more way. I am adding an empty attachment to a mail on exchange server
using CDO. But when i see this mail in outlook/owa, i found attachment size
is change. it's 4 bytes or 64 bytes or 128 bytes. Dont know why but outlook
shows its size. I think if attachment size is 0 bytes then outlook will not
display it in right pane. When i open this attachment in outlook it has no
data. Can i hide this attachment? Means it should not display in right pane
when i select this mail in active explorer. Using CDO when i add this
attachment on exchange server i did not find any way to hide it. So i try in
outlook. I'm using following code to hide it in outlook. Code execute when
click on a mail(which has empty attachment) in active explorer.

Suppose mail item has one empty 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.
 
A

Ashish

Thanks it's the example to use extended mapi in outlook addin which ask to
save mail and attachment after setting property.
Is there any example to set this property using CDO? I tried but could not
get succeed.
 
K

Ken Slovak - [MVP - Outlook]

I have no idea about any examples using CDO, you can google and see if you
can find anything and you can check at www.cdolive.com and see if anything's
there. If there are any I'd imagine they'd be in VB and not in C++.
 

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