How to access the subject of a compose mail item in Outlook
        Posted  
        
            by vwfreak034
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by vwfreak034
        
        
        
        Published on 2010-06-16T17:50:45Z
        Indexed on 
            2010/06/16
            19:52 UTC
        
        
        Read the original article
        Hit count: 382
        
In Outlook, I can set the subject for a new message (when composing a new mail message), but I want to prepend text. So I need to get the subject first, and then set it.
Outlook.Application application = Globals.ThisAddIn.Application;
Outlook.Inspector inspector = application.ActiveInspector();
Outlook.MailItem myMailItem = (Outlook.MailItem)inspector.CurrentItem;
if (myMailItem != null && !string.IsNullOrEmpty(myMailItem.Subject))
{
    myMailItem.Subject = "Following up on your order";
}
This code works on replies, but not for new messages, because in that case, myMailItem is null.
© Stack Overflow or respective owner