I am creating Outlook Add-in which adds a footer to mail after button is pushed.
I have a problem with bookmarks '_MailAutoSig' and '_MailOriginal' which are showed in mailItem.HtmlBody (it contains '' and ' tags), but while i open Mail in WordEditor thers is no Bookmarks at all.
i use following cote to read content of email:
private void logHtml_Click(object sender, RibbonControlEventArgs e)
{
ILog log = LogManager.GetLogger("mailItem");
log.Info(GetMailItem(e).HTMLBody);
}
private void logWord_Click(object sender, RibbonControlEventArgs e)
{
ILog log = LogManager.GetLogger("WordDoc");
Outlook.MailItem mailItem = null;
mailItem = GetMailItem(e);
if (mailItem != null)
{
Word.Document doc = mailItem.GetInspector.WordEditor as Word.Document;
Word.Bookmarks bookmarks = doc.Content.Bookmarks;
foreach (var bookmark in bookmarks)
{
log.Debug(bookmark.ToString());
}
log.Debug(doc.Bookmarks);
log.Debug(doc.Content.Text);
}
}
could you tell me if i'm doing something wrong or what i should do to load mailItem with bookmarks to Word.Document?
I managed to find that in Outlook Bookmarks window there is show hidden option which needs to be checked to see MailOriginal and MailAutoSig bookmarks.
Similarly in Add-in i needed to add doc.Bookmarks.ShowHidden = true;
before getting list of bookmarks to see those 2 hidden bookmarks.
After adding that line all is showing properly.