Click here to Skip to main content
13,143,008 members (53,800 online)
Rate this:
Please Sign up or sign in to vote.
How do i copy the active email message selected text in outlook 2007 using, when the toolbar button is clicked bellow event is fired that event selected text to stored the sql server database how to write the code pls give me any suggestion , i am verify the link but that link <a href=""></a> is , i have code pls give me some idea

private void _objToolBarButton_Click(Office.CommandBarButton ctrl, ref bool cancel)

Thank u
Posted 6-Feb-12 0:51am
Updated 6-Feb-12 0:55am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

private void savenumbers()
Outlook.Application oApp;
Outlook.Explorer oExp;
Outlook.Selection oSel;
object oItem;
long i;
// TODO: On Error GoTo Warning!!!: The statement is not translatable
oApp = new Outlook.Application();
oExp = oApp.ActiveExplorer();
oSel = oExp.Selection;
if ((oSel.Count == 0))
System.Windows.Forms.MessageBox.Show("Nothing selected");
for (i = 1; i <= oSel.Count; i++)
oItem = oSel[i];


catch (System.Exception ex)
System.Windows.Forms.MessageBox.Show("Error " + ex.Message.ToString());
public int outlooksavenumber(string testcopy)

int ReturnValue = 0;
ReturnValue = SqlHelper.ExecuteNonQuery(LITRMSConnection, "usp_Outlooksavenumbers",
new SqlParameter("@testcopy", testcopy));

return ReturnValue;

void DisplayMessage(object oItem)
//Outlook.MailItem oMailItem;
Outlook.MailItem oMail = (Outlook.MailItem)oItem;
string body = oMail.Body;
Outlook.Inspector inspector = oMail.GetInspector;

// Obtain the Word.Document object from the Inspector object
Microsoft.Office.Interop.Word.Document document = (Microsoft.Office.Interop.Word.Document)inspector.WordEditor;

// Copy the selected objects
string testcopy = "";
testcopy = document.Application.Selection.Text;


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 |
Web02 | 2.8.170915.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