Outlook Banter

Outlook Banter (http://www.outlookbanter.com/)
-   Add-ins for Outlook (http://www.outlookbanter.com/add-ins-outlook/)
-   -   Item Save and Saveas events (http://www.outlookbanter.com/add-ins-outlook/88106-item-save-saveas-events.html)

Ashish March 24th 09 11:23 AM

Item Save and Saveas events
 
How to differentiate between save and saveas a mail item. Item_Write call
for both cases and parameters for this function doesn't tell any difference
between two.



Ken Slovak - [MVP - Outlook] March 24th 09 01:42 PM

Item Save and Saveas events
 
You'd most likely have to grab every single menu/toolbar entry that can
perform those commands and handle their Click events. For Outlook 2007 you'd
have to do the same thing with the ribbon also. This would apply not only to
the actions in Inspectors but also when the item is selected in an Explorer.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Ashish" wrote in message
...
How to differentiate between save and saveas a mail item. Item_Write call
for both cases and parameters for this function doesn't tell any
difference between two.



Ashish March 24th 09 03:21 PM

Item Save and Saveas events
 
I tried to capture the event for menu click but could not make it. Is there
any example available. I tried those which are in outlookcode.com but not
mentioned clearly
"Ken Slovak - [MVP - Outlook]" wrote in message
...
You'd most likely have to grab every single menu/toolbar entry that can
perform those commands and handle their Click events. For Outlook 2007
you'd have to do the same thing with the ribbon also. This would apply not
only to the actions in Inspectors but also when the item is selected in an
Explorer.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Ashish" wrote in message
...
How to differentiate between save and saveas a mail item. Item_Write call
for both cases and parameters for this function doesn't tell any
difference between two.





Ken Slovak - [MVP - Outlook] March 24th 09 05:08 PM

Item Save and Saveas events
 
Not a menu click event, but the actual CommandBarButton objects that are
accessed from the menus/toolbars. So you need to instantiate a button
object, declared WithEvents for VB/VBA, representing say File,Save in the
Inspector menus. Then the same for File, SaveAs. And so on for every
possible way to perform those actions. You will need the id properties of
the buttons to grab them. Those can be picked up from a tool like
OutlookSpy.

There are plenty of code samples for using CommandBars.FindControl, which is
what you'd be using. It's up to you to find and grab all relevant
CommandBarButton objects.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Ashish" wrote in message
...
I tried to capture the event for menu click but could not make it. Is there
any example available. I tried those which are in outlookcode.com but not
mentioned clearly



Ashish March 25th 09 10:49 AM

Item Save and Saveas events
 
Thanks. Yes Now i can capture the SaveAs action.
When we click on SaveAs a new "SaveAs" dislog box appear. How to capture
events for this "SaveAs" dislog box.
Means on saveas dialog there are 2 buttons "Save" and "Cancel". I want to
capture events when i click on these buttons.
"Ken Slovak - [MVP - Outlook]" wrote in message
...
Not a menu click event, but the actual CommandBarButton objects that are
accessed from the menus/toolbars. So you need to instantiate a button
object, declared WithEvents for VB/VBA, representing say File,Save in the
Inspector menus. Then the same for File, SaveAs. And so on for every
possible way to perform those actions. You will need the id properties of
the buttons to grab them. Those can be picked up from a tool like
OutlookSpy.

There are plenty of code samples for using CommandBars.FindControl, which
is what you'd be using. It's up to you to find and grab all relevant
CommandBarButton objects.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Ashish" wrote in message
...
I tried to capture the event for menu click but could not make it. Is
there any example available. I tried those which are in outlookcode.com
but not mentioned clearly





Ken Slovak - [MVP - Outlook] March 25th 09 03:02 PM

Item Save and Saveas events
 
There are no events you can capture from that dialog.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Ashish" wrote in message
...
Thanks. Yes Now i can capture the SaveAs action.
When we click on SaveAs a new "SaveAs" dislog box appear. How to capture
events for this "SaveAs" dislog box.
Means on saveas dialog there are 2 buttons "Save" and "Cancel". I want to
capture events when i click on these buttons.



Ashish March 26th 09 07:13 AM

Item Save and Saveas events
 
Oh thats strange. Ok i'll do this task by different way. How to delete a
custom property from mail item.
Suppose i add a new field in mail item on exchange server and i want to
delete this field in outlook addin.
"urn:schemas:mailheader:X-MyField-Name"

IMessagePtr msgptr;
FieldsPtr Flds;

Flds = msgptr-Fields;

Flds-Item[ "urn:schemas:mailheader:X-MyField-Name" ]-Value = "field value"

In outlook addin i can get this field and its value through
HrGetOneProp(PR_TRANSPORT_MESSAGE_HEADERS.)

If i want to delete this field then i think it's possible using HrSetOneProp
..

But HrSetOneProp takes long value as property tag to set value for any
property. I dont know the long value for
urn:schemas:mailheader:X-MyField-Name. I used outspy/mfcmapi but it doesn't
show that field.

"Ken Slovak - [MVP - Outlook]" wrote in message
...
There are no events you can capture from that dialog.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Ashish" wrote in message
...
Thanks. Yes Now i can capture the SaveAs action.
When we click on SaveAs a new "SaveAs" dislog box appear. How to capture
events for this "SaveAs" dislog box.
Means on saveas dialog there are 2 buttons "Save" and "Cancel". I want to
capture events when i click on these buttons.





Ken Slovak - [MVP - Outlook] March 26th 09 01:14 PM

Item Save and Saveas events
 
Well, for one thing if an email is only within an Exchange organization that
property doesn't exist. Internal emails never have a
PR_TRANSPORT_MESSAGE_HEADERS property.

That property, when it does exist, is a text property (PT_STRING8) and there
are no "subfields" in it. It's just a string. You can parse it using string
functions and find that X-header and remove it using string functions.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Ashish" wrote in message
...
Oh thats strange. Ok i'll do this task by different way. How to delete a
custom property from mail item.
Suppose i add a new field in mail item on exchange server and i want to
delete this field in outlook addin.
"urn:schemas:mailheader:X-MyField-Name"

IMessagePtr msgptr;
FieldsPtr Flds;

Flds = msgptr-Fields;

Flds-Item[ "urn:schemas:mailheader:X-MyField-Name" ]-Value = "field
value"

In outlook addin i can get this field and its value through
HrGetOneProp(PR_TRANSPORT_MESSAGE_HEADERS.)

If i want to delete this field then i think it's possible using
HrSetOneProp .

But HrSetOneProp takes long value as property tag to set value for any
property. I dont know the long value for
urn:schemas:mailheader:X-MyField-Name. I used outspy/mfcmapi but it
doesn't show that field.



Ashish March 26th 09 01:24 PM

Item Save and Saveas events
 
Yes i did same. I get value for PR_TRANSPORT_MESSAGE_HEADERS and search
x_header when open item. Then get the value for x_header and remove it. It
works successfully. But when i close item i get value for
PR_TRANSPORT_MESSAGE_HEADERS and set the value of x_header which i
delete.This i do because when i open mail next time x_header should be
there. But this time the value is not set. I tried to set it in
item_close/inspector_deactivate event but value is not set. While if i debug
the program step by step the value is set. Please suggest from where i
should set it when close the item.
"Ken Slovak - [MVP - Outlook]" wrote in message
...
Well, for one thing if an email is only within an Exchange organization
that property doesn't exist. Internal emails never have a
PR_TRANSPORT_MESSAGE_HEADERS property.

That property, when it does exist, is a text property (PT_STRING8) and
there are no "subfields" in it. It's just a string. You can parse it using
string functions and find that X-header and remove it using string
functions.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Ashish" wrote in message
...
Oh thats strange. Ok i'll do this task by different way. How to delete a
custom property from mail item.
Suppose i add a new field in mail item on exchange server and i want to
delete this field in outlook addin.
"urn:schemas:mailheader:X-MyField-Name"

IMessagePtr msgptr;
FieldsPtr Flds;

Flds = msgptr-Fields;

Flds-Item[ "urn:schemas:mailheader:X-MyField-Name" ]-Value = "field
value"

In outlook addin i can get this field and its value through
HrGetOneProp(PR_TRANSPORT_MESSAGE_HEADERS.)

If i want to delete this field then i think it's possible using
HrSetOneProp .

But HrSetOneProp takes long value as property tag to set value for any
property. I dont know the long value for
urn:schemas:mailheader:X-MyField-Name. I used outspy/mfcmapi but it
doesn't show that field.





Ken Slovak - [MVP - Outlook] March 26th 09 05:40 PM

Item Save and Saveas events
 
MAPI properties with a specific GUID are transformed into x-headers when the
item gets sent out, transformed by the message transport from a property
into part of the header. That's the only time that happens. You can grab and
existing PR_TRANSPORT_MESSAGE_HEADERS string and manipulate it using string
functions to add something and write it back. That's about it.

Why not just create an Outlook UserProperty, or if you don't want it to be
available to users create a named MAPI property and use that?

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Ashish" wrote in message
...
Yes i did same. I get value for PR_TRANSPORT_MESSAGE_HEADERS and search
x_header when open item. Then get the value for x_header and remove it. It
works successfully. But when i close item i get value for
PR_TRANSPORT_MESSAGE_HEADERS and set the value of x_header which i
delete.This i do because when i open mail next time x_header should be
there. But this time the value is not set. I tried to set it in
item_close/inspector_deactivate event but value is not set. While if i
debug the program step by step the value is set. Please suggest from where
i should set it when close the item.




All times are GMT +1. The time now is 12:29 PM.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2006 OutlookBanter.com