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:
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);
}
}