Click here to Skip to main content
Rate this: bad
good
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)
               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 6-Feb-12 22:56pm
Edited 8-Feb-12 14:55pm
(no name)41.5K
v2
Comments
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 587
1 Sergey Alexandrovich Kryukov 479
2 Maciej Los 305
3 Mathew Soji 195
4 Richard MacCutchan 145
0 OriginalGriff 7,356
1 Sergey Alexandrovich Kryukov 6,712
2 DamithSL 5,461
3 Manas Bhardwaj 4,916
4 Maciej Los 4,475


Advertise | Privacy | Mobile
Web01 | 2.8.1411023.1 | Last Updated 8 Feb 2012
Copyright © CodeProject, 1999-2014
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