none
Neep help with Outlook VSTO. How to add custom acknowledgement message to Outlook Reply window without tampering old message or format? RRS feed

  • Question

  • Hi,

    I was able to programmatically open Reply window but unable to append the reply message programmatically for Outlook VSTO.  I have a custom acknowledgement message that needs to be sent automatically on a toolbar menu button press. I used mailitem.ReplyAll.Send() in my code to successfully call the reply window and send but it does not allow me to insert acknowledgement message.  If I pass string to the mail body (MailItem.Body), it is losing formatting and if I use MailItem.HTMLBody, then the formatting stays but the acknowledgement message is being inserted just at the start of old message but after the message information, i.e., after From, Sent, Subject, etc., of old message.  I want the acknowledgement message to be on top.  Please help me with sample code if possible.

    Vamshi Vemula


    Vamshi Vemula
    Monday, May 16, 2011 5:07 AM

Answers

  • Hi,

    with the .Display-Method a new Inspector is opened.

    So what you can try is to register for the applications.INspectors.New_Inspector event, and everythime an inspector is opened, check if it's a reply to the message where you clicked the button,

    then insert that text into that body.

    This is the way to go I think. Usually I would use an InspectorWrapper code to handle multiple INspectors, but maybe it's not nessesary in your case.

    I can not post a full solution here for time reasons.
    There are always more solutions to a problem

    I just can point you in a direction...
    how I would solve that specific problem.

    Greets - Helmut

     


    Helmut Obertanner [http://www.obertanner.de] [http://www.outlooksharp.de]
    Monday, May 16, 2011 10:34 AM
    Answerer

All replies

  • Hi,

    how do you insert the Text into the HTMLBody?

    A quick look at the HTMLBoy shows me the HTML, the Word Editor has generated.

    After the <Body> Tag, the First Item is a <p> Tag

     

    <body lang=DE link=blue vlink=purple style='tab-interval:35.4pt'><div class=WordSection1>
    <p class=MsoNormal>

     

    I would try to use HtmlDOM and search for the first <P entity.

    and insert here the HTML Text as

    <p>

    Your text.

    </p>

    Not sure if that helps,

    Greets - Helmut

     

     


    Helmut Obertanner [http://www.obertanner.de] [http://www.outlooksharp.de]
    Monday, May 16, 2011 6:52 AM
    Answerer
  • Hi Helmut,

    Lets consider the below mail as the Reply content that we get after we hit reply button on Outlook mail window.  The problem is when we use MailItem.Body or MailItem.HTMLBody, the content we get is of the mail body, i.e., starting from "Dear XXXXXX," from the below example.  So, somehow the topmost e-mail information portion (From, Sent, To, Subject) is added later when window is opening.  I tried your method and the automatic acknowledge text is being added before "Dear XXXXXX" when MailItem.HTMLBody is used without losing formatting, but I need to insert my acknowledge content like we do manually before information content.

     

    From: XXXXXXXXXXXXXX [mailto:xxxxx@abc.com]
    Sent: Monday, May 16, 2011 8:18 AM
    To: xxxxxxxxxxxxxxxxxxxxx
    Subject:
    SOME SUBJECT

    Dear XXXXXXXXX, 

    Warm greetings from XXXXXXXXX.

    Regards,


    Vamshi Vemula
    Monday, May 16, 2011 8:49 AM
  • Ah ok - now I think I understand. You modify the wrong Item Body.

    Not the new Inspector of the replay, you modify the current Item where you call replyAll.
    You nee somehow get the Body o fthe Reply-Item.

    Is it possible to do what you want in the Item_Send event?

    Greets - Helmut


    Helmut Obertanner [http://www.obertanner.de] [http://www.outlooksharp.de]
    Monday, May 16, 2011 8:56 AM
    Answerer
  • Hi Helmut,

    I am using toolbar button click event for the selected mail, so Item_Send event cannot be used I guess.

    I tried

    MailItem.HTMLBody = "SOME AUTO ACKNOWLEDGEMENT TEXT" & vbNewLine & MailItem.ReplyAll.HTMLBody
    MailItem.ReplyAll.Display()           'This I will change to MailItem.ReplyAll.Send() once code is successfull.

    But , it gave me the following result which has TWO information blocks with the acknowledge text after the first block.

    Can you, if possible, post a sample code?

     

    From: XXXXXXXXXXXXXX [mailto:xxxxx@abc.com]
    Sent: Monday, May 16, 2011 8:18 AM
    To: xxxxxxxxxxxxxxxxxxxxx
    Subject:
    SOME SUBJECT

    SOME AUTO ACKNOWLEDGEMENT TEXT

    From: XXXXXXXXXXXXXX [mailto:xxxxx@abc.com]
    Sent: Monday, May 16, 2011 8:18 AM
    To: xxxxxxxxxxxxxxxxxxxxx
    Subject:
    SOME SUBJECT

    Dear XXXXXXXXX, 

    Warm greetings from XXXXXXXXX.

    Regards,


    Vamshi Vemula
    Monday, May 16, 2011 9:56 AM
  • Hi,

    with the .Display-Method a new Inspector is opened.

    So what you can try is to register for the applications.INspectors.New_Inspector event, and everythime an inspector is opened, check if it's a reply to the message where you clicked the button,

    then insert that text into that body.

    This is the way to go I think. Usually I would use an InspectorWrapper code to handle multiple INspectors, but maybe it's not nessesary in your case.

    I can not post a full solution here for time reasons.
    There are always more solutions to a problem

    I just can point you in a direction...
    how I would solve that specific problem.

    Greets - Helmut

     


    Helmut Obertanner [http://www.obertanner.de] [http://www.outlooksharp.de]
    Monday, May 16, 2011 10:34 AM
    Answerer