How to extract email's body so that looks exactly like in Outlook?


Joined
Sep 2, 2011
Messages
1
Reaction score
0
I have a task - keep correspondence with certain Contacts in database

I do it in that way:
1. Create event handler for ItemSend
2. Read Subject and HTMLBody
3. Send them as strings to ms sql database
4. In my application get string from database , show it in WebBroser control as HTML text

But I cannt see images included in email's body
How I can save the Body with all attached images in HTML format? Is it possible?

And other problem I can not get addreses : To, CC and From they always = null

Here is my code:

Code:
    public partial class ThisAddIn
    {
        public Outlook.Application OutlookApplication;
        private void ThisAddIn_Startup(object sender, System.EventArgs e)
        {
            OutlookApplication = this.Application;
            OutlookApplication.ItemSend += new Microsoft.Office.Interop.Outlook.ApplicationEvents_11_ItemSendEventHandler(OutlookApplication_ItemSend);
        }
        private void OutlookApplication_ItemSend(object Item, ref bool Cancel)
        {
            string EmailTo = String.Empty  ;
            string EmailFrom = String.Empty;
            string Subject = String.Empty;
            string Body = String.Empty;
            Outlook.MailItem mailItem = Item as Outlook.MailItem;
            if (mailItem != null)
            {
                if (mailItem.EntryID == null)
                {
                    EmailTo = mailItem.To;
                    EmailFrom = mailItem.SenderEmailAddress;
                    Subject = mailItem.Subject;
                    Body = mailItem.HTMLBody;
                }
            }
            SendToDB(EmailTo,  EmailFrom,  Subject,  Body);
        }
     }
 
Ad

Advertisements


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