Insert text at the start of mailitem.Body in VSTO Outlook using C#

  • Thread starter Thread starter Ankit S Rawat
  • Start date Start date
A

Ankit S Rawat

Guest
I am trying to insert some text whenever user composing a new mail OR Reply OR ReplyAll. I am able to capture all these 3 events and work on editor after event the occurrence.

Now I want to insert some text at the beginning of the editor(the editor box where user type message), for which I tried:

1) Insert method:


mailItem.Body = mailItem.Body.Insert(0, "Some Text");


This line of code is throwing NullReferenceException.

2) Next, I tried to use Native approach :


mailItem.Body = "Some Text " + mailItem.Body;


This is appending text at the starting of mail body, but the formatting vanishes which is not acceptable at all.

I think HTMLBody can help, but no idea how to use it. Can anybody please help?

Continue reading...
 
Back
Top