none
How to Dynamically Add a content at the Cursor Position. Even if the Cursor is in Subject Field RRS feed

  • Question

  • Hi, 

    I have dynamically inserted the Text to the mail body using the Following code , 

    But its only insert data only in mail Body. I want to add the content even in the mail subject . The Content will be in the Ribbon.

    This must happen based on the cursor Position. How to Achive this 

    My Code

    Inspector explObj = Globals.ThisAddIn.Application.ActiveInspector();

     Microsoft.Office.Interop.Word.Document objDoc =explobj.WordEditor;

    Microsoft.Office.Interop.Word.Selection obselection = objDoc.Application.Selection;

    ThanksinAdvance


    Tuesday, April 4, 2017 3:00 PM

All replies

  • Hello,

    It is impossible to add content in subject using WordEditor. WordEditor only works for item bodies. For more information, please visit Chapter 17: Working with Item Bodies. To add subject, we need to use MailItem.Subject Property.

    Regards,

    Celeste


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, April 5, 2017 2:46 AM
    Moderator
  • Hi , 

    Thanks for the reply . 

    So how to get the cursor position in a mail composing Screen . 

    if the Cursor position in not in the mail body how to find out that?

    so that based on that i can place data in mail subject 

    Thanks for the reply in advance

    Wednesday, April 5, 2017 1:00 PM
  • Hello,

    Why do you want to check if the cursor position in Subject field? If you don't want users to change subject, you could handle MailItem.PropertyChange Event (Outlook) and then reset the subject property.

    Outlook object model doesn't provide any API to get cursor position at Subject.

    To achieve that, you may use Windows API. Please visit the similar thread: http://stackoverflow.com/questions/38433898/c-sharp-outlook-how-can-i-get-the-cursor-position-in-the-subject-field-of-a-ma

    Regards,

    Celeste


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, April 6, 2017 9:06 AM
    Moderator