1
votes

I am developing an Outlook add-in using VSTO that checking spelling of the mail content while composing. In Reply mails, How can I check only the reply content by excluding the old conversation ? This is what I am doing now.But I need to know whether there is any proper object or method to get current reply content.

Outlook.MailItem mailItem = inspector.CurrentItem as Outlook.MailItem;
                string temp = mailItem.Body;
                int target= temp.IndexOf("\r\nFrom:");
                string contentToCheck= temp.Substring(0, target);

FYI

2

2 Answers

1
votes

There is no built in property that signifies the end of the new message and the start of a reply in body text.

What can be done is store common text that marks the end of the new message and check for that when reading the body. Things like ' FROM:', 'Regards,' 'Thanks,'...

Something similar to:

while ((line = bodytext.ReadLine()) != null)
{
    foreach(string ending in MYLISTOFCOMMONENDINGS)
                     {
                         if (line.StartsWith(ending))
                             return sb.ToString();  //we are done
//here sb is a string builder consuming new lines
                     }
        //read the line and check spelling
} 
0
votes

Look for the bookmark named "_MailOriginal". The script below inserts text just before the original message begins:

set objDoc = Application.ActiveInspector.WordEditor
If objDoc.Bookmarks.Exists("_MailOriginal") Then
  ' is there the original email? (_MailOriginal)
  set objBkm = objDoc.Bookmarks("_MailOriginal")
  Set objSel = objDoc.Application.Selection
  objSel.Start = objBkm.Start-2 'give room for the line break before. It includes the line
  objSel.End = objSel.Start
  objSel.Text = "test"
End If