J
James C
Hi,
I'm writing a C# Outlook add-in for MS Outlook 2003. The functionality I
require is to pass the contents of the "to" and "cc" fields on an email form
to a custom form (popped via a custom toolbar button).
Therefore, if a user throws a new email form, enters text into the fields,
then uses the custom toolbar to throw my email form, I need to be able to
access each control on the email form and read what the user has entered.
I have successfully added the custom toolbar and can throw my new form from
the Outlook email form, however, I don't know how to reference the "To",
"CC", "Subject" and "mail body" fields at the time my toolbar button is
selected.
I've tried doing the following in the
_CommandBarButtonEvents_ClickEventHandler event of my CommandBarButton object:
----------------------------------------
objMailItem =
(Microsoft.Office.Interop.Outlook.MailItem)myInspector.CurrentItem;
MessageBox.Show("objMailItem.To = " + objMailItem.To);
MessageBox.Show("objMailItem.Subject = " + objMailItem.Subject);
//Results in objMailItem.To and objMailItem.Subject being empty string, even
if
//the user has amended the fields
-------------------------------------------------------
but objMailItems .to and .subject properties only return the properties at
the time the email form was thrown, not at the time the command button was
clicked. Thus, I can't access any text entered by the user in these fields.
Any help or pointers would be really appreciated on this - it's been driving
me mad for days!
Many thanks.
James
I'm writing a C# Outlook add-in for MS Outlook 2003. The functionality I
require is to pass the contents of the "to" and "cc" fields on an email form
to a custom form (popped via a custom toolbar button).
Therefore, if a user throws a new email form, enters text into the fields,
then uses the custom toolbar to throw my email form, I need to be able to
access each control on the email form and read what the user has entered.
I have successfully added the custom toolbar and can throw my new form from
the Outlook email form, however, I don't know how to reference the "To",
"CC", "Subject" and "mail body" fields at the time my toolbar button is
selected.
I've tried doing the following in the
_CommandBarButtonEvents_ClickEventHandler event of my CommandBarButton object:
----------------------------------------
objMailItem =
(Microsoft.Office.Interop.Outlook.MailItem)myInspector.CurrentItem;
MessageBox.Show("objMailItem.To = " + objMailItem.To);
MessageBox.Show("objMailItem.Subject = " + objMailItem.Subject);
//Results in objMailItem.To and objMailItem.Subject being empty string, even
if
//the user has amended the fields
-------------------------------------------------------
but objMailItems .to and .subject properties only return the properties at
the time the email form was thrown, not at the time the command button was
clicked. Thus, I can't access any text entered by the user in these fields.
Any help or pointers would be really appreciated on this - it's been driving
me mad for days!
Many thanks.
James