Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi All,

This is the scenario..

The user selects a part of the mail message/body and I should be able to copy the selected items and it stores to sql server database
C#
Outlook.Application myApplication = Globals.ThisAddIn.Application;
           Outlook.Explorer myActiveExplorer = (Outlook.Explorer)myApplication.ActiveExplorer();

           Outlook.Selection selection = myActiveExplorer.Selection;

           if (selection.Count == 1 && selection[1] is Outlook.MailItem)
           {
               Outlook.MailItem mail = (Outlook.MailItem)selection[1];

               mail.Copy(); // currently opened mail

               Outlook.MailItem mailItem = (Outlook.MailItem)
              myApplication.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem);

               mailItem.Subject = mail.Subject;
               mailItem.To = mail.To;

               mailItem.Body = ?????      // copy only selected text/images of user

               mailItem.Importance = Outlook.OlImportance.olImportanceLow;
               mailItem.Display(true);
           }

On the mailITem.Body, I just want to paste the selected text/images of the user from the selected mail (// currently opened mail).
How can I implement it, I cant find the paste method.
I would greatly appreciate any suggestions or examples.

Thanks
Ravi Chaitanya
Posted
Updated 8-Feb-12 13:55pm
v2
Comments
db7uk 23-Apr-12 17:50pm    
Firstly this is fairly complicated.
First you will need to interact with the windows clipboard. Once you find the copied text you will then be able to parse it as (html)text and store it. Images are more complicated because of how outlook stores them. All images are stored as attachments and embedded images (in this case) are stored as hidden attachments identified by the CID of the image.

The image (if copied to the clipboard) may be present in the collection however I have never tried this..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900