Change body of received mail

R

roaddc

I need to develop an Outlook Add-In using C# that appends a footer text
to some of the received mail and save it.

Is this possible?

I tried the following code but I'm getting errors in Outlook:

myMailItem.HTMLBody += "Testing footer";
myMailItem.Save();

Thanks.
 
K

Ken Slovak - [MVP - Outlook]

What errors are you getting? That should work if you are using Outlook 2003
and have written your addin using the trusted addin model. All Outlook
objects should be derived from the Application object passed to you in the
OnConnection event handler.

See if breaking the += line into two lines helps. Read the existing HTMLBody
as a string, append what you want and write it back.
 
R

roaddc

Ok. The error I got was for something else.

I was able to append to the MailItem Body and save it but it doesn't
reflect the changed message body until I close and reopen the MailItem.

I was trying to append on the body during the MailItem Open event and
also on MailItem's creation but it still didn't reflect the change
right away.

Somebody suggested that I do it at the ItemAdded event but I don't know
which object has that event.
 
K

Ken Slovak - [MVP - Outlook]

ItemAdd is an event of the Items collection. Use the Object Browser to
review methods, events and properties of any Outlook object or collection.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top