Click here to Skip to main content
13,049,814 members (71,790 online)
Rate this:
Please Sign up or sign in to vote.
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
 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)
                mailItem.Subject = mail.Subject;
                mailItem.To = mail.To;
                mailItem.Body = ?????      // copy only selected text/images of user 
                mailItem.Importance = Outlook.OlImportance.olImportanceLow;

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.

Ravi Chaitanya
Posted 6-Feb-12 21:56pm
Updated 8-Feb-12 13:55pm
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)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 8 Feb 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100