Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: SQL-Server-2008 C#4.0 Outlook , +
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 22:56pm
Edited 8-Feb-12 14:55pm
(no name)41.6K
db7uk at 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
0 OriginalGriff 490
1 Sergey Alexandrovich Kryukov 335
2 ProgramFOX 265
3 Maciej Los 245
4 Andreas Gieriet 200
0 OriginalGriff 465
1 Sergey Alexandrovich Kryukov 275
2 ProgramFOX 265
3 Maciej Los 245
4 Andreas Gieriet 200

Advertise | Privacy | Mobile
Web04 | 2.8.150331.1 | Last Updated 8 Feb 2012
Copyright © CodeProject, 1999-2015
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