A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Add-ins for Outlook
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Changes to Subject in MailItem not reflected



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old May 31st 08, 04:32 AM posted to microsoft.public.outlook.program_addins
DavidReck
external usenet poster
 
Posts: 3
Default Changes to Subject in MailItem not reflected

I have added a group to an existing tab in the outlook 07 ribbon. One of the
controls in my group is a button that tries to read the subject from a mail
item and then append some text. If it is a new mail item the subject always
starts as null even if I have typed values in the email's subject. If it is
a reply to an existing email the subject always comes in as the originals
email's subject even if I changed it before clicking the button. I am
somewhat new to this so it could be a simple problem. It almost seems like
the subject is based on the first loading of the outlook email window and I
need to refresh it somehow before I read the value of the subject. Here is
my code.

private void EncryptEmailButton_Click(object sender,
RibbonControlEventArgs e)
{
try
{
Debug.WriteLine("EncryptEmailButton_Click");
this.BypassEncryptionEmail.Checked = false;
Microsoft.Office.Interop.Outlook.Inspector window =
Globals.ThisAddIn.Application.ActiveInspector();
if (window != null)
{
Microsoft.Office.Interop.Outlook.MailItem mail =

(Microsoft.Office.Interop.Outlook.MailItem)window. CurrentItem;
if (mail != null)
{
if (mail.Subject != null)
mail.Subject = StripMessages(mail.Subject);
mail.Subject = mail.Subject + " - Secured";
}
}
}
catch (Exception ex)
{
Debug.WriteLine(ex.Message);
}
}

Thanks for your help

Ads
  #2  
Old June 2nd 08, 03:55 PM posted to microsoft.public.outlook.program_addins
DavidReck
external usenet poster
 
Posts: 3
Default Changes to Subject in MailItem not reflected

Well I figured out a little more. The subject of the email does get updated
but only when I leave the subject text box. If I change the subject and hit
the button the MailItem object does not reflect the changes made to the
subject, but if I change the subject, tab out of the field, and then hit the
button the MailItem objects contains the most updated version. I also
noticed that the title bar across the top of the email item is updated only
after you leave the subject field. If I want to be sure that I am getting
the most current text from the subject do I have to use the MAPIOBJECT
somehow? Any help would greatly be appreciated.

"DavidReck" wrote:

I have added a group to an existing tab in the outlook 07 ribbon. One of the
controls in my group is a button that tries to read the subject from a mail
item and then append some text. If it is a new mail item the subject always
starts as null even if I have typed values in the email's subject. If it is
a reply to an existing email the subject always comes in as the originals
email's subject even if I changed it before clicking the button. I am
somewhat new to this so it could be a simple problem. It almost seems like
the subject is based on the first loading of the outlook email window and I
need to refresh it somehow before I read the value of the subject. Here is
my code.

private void EncryptEmailButton_Click(object sender,
RibbonControlEventArgs e)
{
try
{
Debug.WriteLine("EncryptEmailButton_Click");
this.BypassEncryptionEmail.Checked = false;
Microsoft.Office.Interop.Outlook.Inspector window =
Globals.ThisAddIn.Application.ActiveInspector();
if (window != null)
{
Microsoft.Office.Interop.Outlook.MailItem mail =

(Microsoft.Office.Interop.Outlook.MailItem)window. CurrentItem;
if (mail != null)
{
if (mail.Subject != null)
mail.Subject = StripMessages(mail.Subject);
mail.Subject = mail.Subject + " - Secured";
}
}
}
catch (Exception ex)
{
Debug.WriteLine(ex.Message);
}
}

Thanks for your help

  #3  
Old June 2nd 08, 04:18 PM posted to microsoft.public.outlook.program_addins
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default Changes to Subject in MailItem not reflected

Try calling Save first. The changes made in the UI are committed if the user leaves the control or saves the item.

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


"DavidReck" wrote in message ...
Well I figured out a little more. The subject of the email does get updated
but only when I leave the subject text box. If I change the subject and hit
the button the MailItem object does not reflect the changes made to the
subject, but if I change the subject, tab out of the field, and then hit the
button the MailItem objects contains the most updated version. I also
noticed that the title bar across the top of the email item is updated only
after you leave the subject field. If I want to be sure that I am getting
the most current text from the subject do I have to use the MAPIOBJECT
somehow? Any help would greatly be appreciated.

"DavidReck" wrote:

I have added a group to an existing tab in the outlook 07 ribbon. One of the
controls in my group is a button that tries to read the subject from a mail
item and then append some text. If it is a new mail item the subject always
starts as null even if I have typed values in the email's subject. If it is
a reply to an existing email the subject always comes in as the originals
email's subject even if I changed it before clicking the button. I am
somewhat new to this so it could be a simple problem. It almost seems like
the subject is based on the first loading of the outlook email window and I
need to refresh it somehow before I read the value of the subject. Here is
my code.

private void EncryptEmailButton_Click(object sender,
RibbonControlEventArgs e)
{
try
{
Debug.WriteLine("EncryptEmailButton_Click");
this.BypassEncryptionEmail.Checked = false;
Microsoft.Office.Interop.Outlook.Inspector window =
Globals.ThisAddIn.Application.ActiveInspector();
if (window != null)
{
Microsoft.Office.Interop.Outlook.MailItem mail =

(Microsoft.Office.Interop.Outlook.MailItem)window. CurrentItem;
if (mail != null)
{
if (mail.Subject != null)
mail.Subject = StripMessages(mail.Subject);
mail.Subject = mail.Subject + " - Secured";
}
}
}
catch (Exception ex)
{
Debug.WriteLine(ex.Message);
}
}

Thanks for your help

 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Changes to Subject in MailItem not reflected DavidReck Outlook - Using Forms 1 June 5th 08 09:47 PM
Responses from meeting attendees are not reflected on Tracking tab MW Outlook - Calandaring 3 July 27th 07 06:02 PM
Outlook 2003 - contacts only partially reflected in the addressboo Ensy Outlook - Using Contacts 3 May 26th 06 12:47 AM
Change of names/addresses should be reflected in adressbook-group TheoG Outlook - Using Contacts 0 May 24th 06 09:39 AM
How can I create a MailItem that displays like a received MailItem ? Clive Outlook - Using Forms 0 February 27th 06 04:14 PM


All times are GMT +1. The time now is 09:22 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright 2004-2025 Outlook Banter.
The comments are property of their posters.