使用Outlook复制邮件中的所选文本 [英] Copy Selected text from message with outlook Add in
问题描述
当使用工具栏按钮单击时,如何使用C#.net在Outlook 2007中复制活动电子邮件选择的文本,以下事件被触发,该事件选择的文本存储到sql server数据库中,如何编写代码请给我任何建议,我验证链接,但该链接< a href ="http://www.vbforums.com/showthread.php?t=451995"</a>是VB.net,我有c#.net代码,请给我一些想法
私有void _objToolBarButton_Click(Office.CommandBarButton ctrl,参考布尔取消)
谢谢你
RaviChaitanya
Hi,
How do i copy the active email message selected text in outlook 2007 using C#.net, 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="http://www.vbforums.com/showthread.php?t=451995"></a> is VB.net , i have c#.net code pls give me some idea
private void _objToolBarButton_Click(Office.CommandBarButton ctrl, ref bool cancel)
Thank u
RaviChaitanya
推荐答案
private void savenumbers()
{
试试
{
Outlook.Application oApp;
Outlook.Explorer oExp;
Outlook.Selection oSel;
对象oItem;
长我;
//TODO:出现错误时转到警告!!!:该语句不可翻译
oApp =新的Outlook.Application();
oExp = oApp.ActiveExplorer();
oSel = oExp.Selection;
如果((oSel.Count == 0))
{
System.Windows.Forms.MessageBox.Show(未选择任何内容");
返回;
}
对于(i = 1; i< = oSel.Count; i ++)
{
oItem = oSel [i];
DisplayMessage(oItem);
}
}
捕获(System.Exception ex)
{
System.Windows.Forms.MessageBox.Show("Error" + ex.Message.ToString());
}
}
public int outlooksavenumber(字符串testcopy)
{
int ReturnValue = 0;
ReturnValue = SqlHelper.ExecuteNonQuery(LITRMSConnection,"usp_Outlooksavenumbers",
新的SqlParameter("@ testcopy",testcopy));
return ReturnValue;
}
void DisplayMessage(对象oItem)
{
//Outlook.MailItem oMailItem;
Outlook.MailItem oMail =(Outlook.MailItem)oItem;
//System.Windows.Forms.MessageBox.Show(oMail.Subject);
//System.Windows.Forms.MessageBox.Show(oMail.Body);
字符串正文= oMail.Body;
Outlook.Inspector检查器= oMail.GetInspector;
//从检查器对象中获取Word.Document对象
Microsoft.Office.Interop.Word.Document文档=(Microsoft.Office.Interop.Word.Document)inspector.WordEditor;
//复制选定的对象
字符串testcopy =";
testcopy = document.Application.Selection.Text;
outlooksavenumber(testcopy);
}
private void savenumbers()
{
try
{
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");
return;
}
for (i = 1; i <= oSel.Count; i++)
{
oItem = oSel[i];
DisplayMessage(oItem);
}
}
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;
//System.Windows.Forms.MessageBox.Show(oMail.Subject);
//System.Windows.Forms.MessageBox.Show(oMail.Body);
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;
outlooksavenumber(testcopy);
}
这篇关于使用Outlook复制邮件中的所选文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!