本文整理汇总了C#中Microsoft.Office.Interop.Outlook.Application.ActiveExplorer方法的典型用法代码示例。如果您正苦于以下问题:C# Application.ActiveExplorer方法的具体用法?C# Application.ActiveExplorer怎么用?C# Application.ActiveExplorer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Office.Interop.Outlook.Application
的用法示例。
在下文中一共展示了Application.ActiveExplorer方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: button1_Click
private void button1_Click(object sender, RibbonControlEventArgs e)
{
Outlook.Application application = new Outlook.Application();
Outlook.NameSpace ns = application.GetNamespace("MAPI");
try
{
//get selected mail item
Object selectedObject = application.ActiveExplorer().Selection[1];
Outlook.MailItem selectedMail = (Outlook.MailItem)selectedObject;
//create message
Outlook.MailItem newMail = application.CreateItem(Outlook.OlItemType.olMailItem) as Outlook.MailItem;
newMail.Recipients.Add(ReadFile());
newMail.Subject = "SPAM";
newMail.Attachments.Add(selectedMail, Microsoft.Office.Interop.Outlook.OlAttachmentType.olEmbeddeditem);
newMail.Send();
selectedMail.Delete();
System.Windows.Forms.MessageBox.Show("Spam notification has been sent.");
}
catch
{
System.Windows.Forms.MessageBox.Show("You must select a message to report.");
}
}
示例2: ForwardEmailUsingOutLook
public void ForwardEmailUsingOutLook(string witBody, String witName, List<Docs> docs)
{
Microsoft.Office.Interop.Outlook.Application outlookApp = new Microsoft.Office.Interop.Outlook.Application();
if (outlookApp.ActiveExplorer().Selection.Count > 0)
{
Object selectedMail = outlookApp.ActiveExplorer().Selection[1];
if (selectedMail is Microsoft.Office.Interop.Outlook.MailItem)
{
Microsoft.Office.Interop.Outlook.MailItem mail = (selectedMail as Microsoft.Office.Interop.Outlook.MailItem);
Microsoft.Office.Interop.Outlook.MailItem forwardMail = mail.Forward();
Microsoft.Office.Interop.Outlook.MailItem email =
(Microsoft.Office.Interop.Outlook.MailItem)outlookApp.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem);
email.BodyFormat = Microsoft.Office.Interop.Outlook.OlBodyFormat.olFormatRichText;
email.HTMLBody = witBody + forwardMail.HTMLBody;
//email.To = mail.SenderEmailAddress;
email.Subject = forwardMail.Subject;
if (docs != null && docs.Count > 0)
{
foreach (var doc in docs)
{
if (doc.docId != null)
{
email.Attachments.Add(doc.localPath + "" + doc.fileName, Microsoft.Office.Interop.Outlook.OlAttachmentType.olByValue, 100000, Type.Missing);
}
}
}
email.Display(true);
}
}
}
示例3: MailItems
static public outlook.MailItem[] MailItems()
{
Microsoft.Office.Interop.Outlook.Application app = null;
app = new Microsoft.Office.Interop.Outlook.Application();
ArrayList mailItems = new ArrayList();
foreach (var selection in app.ActiveExplorer().Selection)
{
if (selection is outlook.MailItem)
{
mailItems.Add((outlook.MailItem)selection);
}
}
return (outlook.MailItem[])mailItems.ToArray(typeof(outlook.MailItem));
}
示例4: ThisAddIn_Startup
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
// Initialize variables.
m_Application = this.Application;
m_Explorers = m_Application.Explorers;
m_Inspectors = m_Application.Inspectors;
m_Windows = new List<OutlookExplorer>();
m_InspectorWindows = new List<OutlookInspector>();
// Wire up event handlers to handle multiple Explorer windows.
m_Explorers.NewExplorer +=
new Outlook.ExplorersEvents_NewExplorerEventHandler(m_Explorers_NewExplorer);
// Wire up event handler to handle multiple Inspector windows.
m_Inspectors.NewInspector +=
new Outlook.InspectorsEvents_NewInspectorEventHandler(m_Inspectors_NewInspector);
// Add the ActiveExplorer to m_Windows.
Outlook.Explorer expl = m_Application.ActiveExplorer()
as Outlook.Explorer;
OutlookExplorer window = new OutlookExplorer(expl);
m_Windows.Add(window);
// Hook up event handlers for window.
window.Close += new EventHandler(WrappedWindow_Close);
window.InvalidateControl += new EventHandler<OutlookExplorer.InvalidateEventArgs>(WrappedWindow_InvalidateControl);
// Get IPictureDisp for CurrentUser on startup.
try
{
Outlook.AddressEntry addrEntry =
Globals.ThisAddIn.Application.Session.CurrentUser.AddressEntry;
if (addrEntry.Type == "EX")
{
Outlook.ExchangeUser exchUser =
addrEntry.GetExchangeUser() as Outlook.ExchangeUser;
m_pictdisp = exchUser.GetPicture() as stdole.IPictureDisp;
}
}
catch (Exception ex)
{
// Write exception to debug window.
Debug.WriteLine(ex.Message);
}
}
示例5: OnStartupComplete
public void OnStartupComplete(ref System.Array custom)
{
/*
* When outlook is opened it loads a Menu if Outlook plugin is installed.
* OpenERP - > Push, Partner ,Documents, Configuration
*/
Microsoft.Office.Interop.Outlook.Application app = null;
try
{
app = new Microsoft.Office.Interop.Outlook.Application();
object omissing = System.Reflection.Missing.Value;
menuBar = app.ActiveExplorer().CommandBars.ActiveMenuBar;
ConfigManager config = new ConfigManager();
config.LoadConfigurationSetting();
OpenERPOutlookPlugin openerp_outlook = Cache.OpenERPOutlookPlugin;
OpenERPConnect openerp_connect = openerp_outlook.Connection;
try
{
if (openerp_connect.URL != null && openerp_connect.DBName != null && openerp_connect.UserId != null && openerp_connect.pswrd != "")
{
string decodpwd = Tools.DecryptB64Pwd(openerp_connect.pswrd);
openerp_connect.Login(openerp_connect.DBName, openerp_connect.UserId, decodpwd);
}
}
catch(Exception )
{
MessageBox.Show("Unable to connect remote Server ' " + openerp_connect.URL + " '.", "OpenERP Connection",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);
}
newMenuBar = (office.CommandBarPopup)menuBar.Controls.Add(office.MsoControlType.msoControlPopup, omissing, omissing, omissing, true);
if (newMenuBar != null)
{
newMenuBar.Caption = "OpenERP";
newMenuBar.Tag = "My";
btn_open_partner = (office.CommandBarButton)newMenuBar.Controls.Add(office.MsoControlType.msoControlButton, omissing, omissing, 1, true);
btn_open_partner.Style = office.MsoButtonStyle.msoButtonIconAndCaption;
btn_open_partner.Caption = "Contact";
//Face ID will use to show the ICON in the left side of the menu.
btn_open_partner.FaceId = 3710;
newMenuBar.Visible = true;
btn_open_partner.Click += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(this.btn_open_partner_Click);
btn_open_document = (office.CommandBarButton)newMenuBar.Controls.Add(office.MsoControlType.msoControlButton, omissing, omissing, 2, true);
btn_open_document.Style = office.MsoButtonStyle.msoButtonIconAndCaption;
btn_open_document.Caption = "Documents";
//Face ID will use to show the ICON in the left side of the menu.
btn_open_document.FaceId = 258;
newMenuBar.Visible = true;
btn_open_document.Click += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(this.btn_open_document_Click);
btn_open_configuration_form = (office.CommandBarButton)newMenuBar.Controls.Add(office.MsoControlType.msoControlButton, omissing, omissing, 3, true);
btn_open_configuration_form.Style = office.MsoButtonStyle.msoButtonIconAndCaption;
btn_open_configuration_form.Caption = "Configuration";
//Face ID will use to show the ICON in the left side of the menu.
btn_open_configuration_form.FaceId = 5644;
newMenuBar.Visible = true;
btn_open_configuration_form.Click += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(this.btn_open_configuration_form_Click);
}
}
catch (Exception)
{
object oActiveExplorer;
oActiveExplorer = applicationObject.GetType().InvokeMember("ActiveExplorer", BindingFlags.GetProperty, null, applicationObject, null);
oCommandBars = (office.CommandBars)oActiveExplorer.GetType().InvokeMember("CommandBars", BindingFlags.GetProperty, null, oActiveExplorer, null);
}
}
示例6: countMail
public int countMail()
{
/*
* Gives the number of selected mail.
* returns: Number of selected mail.
*/
cnt_mail = 0;
Microsoft.Office.Interop.Outlook.Application app = null;
app = new Microsoft.Office.Interop.Outlook.Application();
foreach (var selection in app.ActiveExplorer().Selection)
{
cnt_mail = app.ActiveExplorer().Selection.Count;
}
return cnt_mail;
}
示例7: AddAssociation
public void AddAssociation(Element element, string fileFullName, ElementAssociationType type, string text)
{
string noteText = String.Empty;
string shortcutName = String.Empty;
string folderPath = element.Path;
string title = string.Empty;
List<Element> emailAttachmentElementList = new List<Element>();
if (text != null)
{
noteText = text;
if (noteText.Length > StartProcess.MAX_EXTRACTTEXT_LENGTH)
{
noteText = noteText.Substring(0, StartProcess.MAX_EXTRACTTEXT_LENGTH) + "...";
}
title = noteText.Replace("/", "").Replace("\\", "").Replace("*", "").Replace("?", "").Replace("\"", "").Replace("<", "").Replace(">", "").Replace("|", "").Replace(":", "");
if (title.Length > StartProcess.MAX_EXTRACTNAME_LENGTH)
title = title.Substring(0, StartProcess.MAX_EXTRACTNAME_LENGTH);
while (title.EndsWith("."))
title.TrimEnd('.');
}
if (type == ElementAssociationType.File)
{
}
else if (type == ElementAssociationType.FileShortcut)
{
if (text == null)
{
noteText = noteText = System.IO.Path.GetFileNameWithoutExtension(fileFullName);
title = noteText;
}
string fs_fileName = title + System.IO.Path.GetExtension(fileFullName);
shortcutName = ShortcutNameConverter.GenerateShortcutNameFromFileName(fs_fileName, folderPath);
}
else if (type == ElementAssociationType.FolderShortcut)
{
if (fileFullName.EndsWith(System.IO.Path.DirectorySeparatorChar.ToString()))
{
fileFullName = fileFullName.Substring(0, fileFullName.Length - 1);
}
noteText = System.IO.Path.GetFileName(fileFullName);
string fs_fileName = noteText;
shortcutName = ShortcutNameConverter.GenerateShortcutNameFromFileName(fs_fileName, folderPath);
}
else if (type == ElementAssociationType.Web)
{
if (text == null)
{
ActiveWindow activeWindow = new ActiveWindow();
title = activeWindow.GetActiveWindowText(activeWindow.GetActiveWindowHandle());
if(title.Contains(" - Windows Internet Explorer"))
{
// IE
int labelIndex1 = title.LastIndexOf(" - Windows Internet Explorer");
if (labelIndex1 != -1)
{
title = title.Remove(labelIndex1);
noteText = title;
}
}else if(title.Contains(" - Mozilla Firefox"))
{
// Firefox
int labelIndex2 = title.LastIndexOf(" - Mozilla Firefox");
if (labelIndex2 != -1)
{
title = title.Remove(labelIndex2);
noteText = title;
}
}else
{
noteText = fileFullName;
title = string.Empty;
}
if (noteText.Length > StartProcess.MAX_EXTRACTTEXT_LENGTH)
{
noteText = noteText.Substring(0, StartProcess.MAX_EXTRACTTEXT_LENGTH) + "...";
}
}
shortcutName = ShortcutNameConverter.GenerateShortcutNameFromWebTitle(title, folderPath);
}
else if (type == ElementAssociationType.Email)
{
Outlook.Application outlookApp = new Outlook.Application();
Outlook.MailItem mailItem = null;
if (outlookApp.ActiveExplorer().Selection.Count > 0)
{
mailItem = outlookApp.ActiveExplorer().Selection[1] as Outlook.MailItem;
if (mailItem == null)
return;
if (mailItem != null)
{
//.........这里部分代码省略.........
示例8: sendToFreshdesk_Click
private void sendToFreshdesk_Click(object sender, RibbonControlEventArgs e)
{
Outlook._Application oApp = new Outlook.Application();
if (oApp.ActiveExplorer().Selection.Count > 0)
{
Object selObject = oApp.ActiveExplorer().Selection[1];
if (selObject is Outlook.MailItem)
{
Outlook.MailItem mailItem = (selObject as Outlook.MailItem);
String from = mailItem.SenderEmailAddress.ToString();
String fromName = mailItem.SenderName.ToString();
String htmlBody = mailItem.HTMLBody;
String Body = mailItem.Body;
String subject = mailItem.Subject;
Body = Body.Replace("\r\n", "\\n");
htmlBody = htmlBody.Replace("\r\n", "");
string json = "{\"helpdesk_ticket\": {\"email\":\"" + from + "\",\"name\":\"" + fromName + "\",\"subject\":\"" + subject + "\",\"description\":\"" + Body + "\",\"description_html\":\"" + htmlBody + "\"}}";
//string json = "{\"helpdesk_ticket\": {\"email\":\"[email protected]\",\"subject\":\"test\",\"description\":\"confirm whether received\"}}";
MessageBox.Show(json);
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://nctas.freshdesk.com/helpdesk/tickets.json");
//HttpWebRequest class is used to Make a request to a Uniform Resource Identifier (URI).
request.ContentType = "application/json";
// Set the ContentType property of the WebRequest.
request.Method = "POST";
byte[] byteArray = Encoding.UTF8.GetBytes(json);
// Set the ContentLength property of the WebRequest.
request.ContentLength = byteArray.Length;
string authInfo = "APIKEY:X";
authInfo = Convert.ToBase64String(Encoding.Default.GetBytes(authInfo));
request.Headers["Authorization"] = "Basic " + authInfo;
//Get the stream that holds request data by calling the GetRequestStream method.
Stream dataStream = request.GetRequestStream();
// Write the data to the request stream.
dataStream.Write(byteArray, 0, byteArray.Length);
// Close the Stream object.
dataStream.Close();
WebResponse response = request.GetResponse();
// Get the stream containing content returned by the server.
//Send the request to the server by calling GetResponse.
dataStream = response.GetResponseStream();
// Open the stream using a StreamReader for easy access.
StreamReader reader = new StreamReader(dataStream);
// Read the content.
string Response = reader.ReadToEnd();
//return the response
Console.Out.WriteLine(Response);
//MessageBox.Show(fromName);
/*if (mailItem.Attachments.Count > 0)
{
for (int i = 1; i <= mailItem.Attachments.Count; i++)
{
MessageBox.Show(mailItem.Attachments[i].FileName.ToString());
}
}*/
}
}
}
示例9: getActiveLetter
public void getActiveLetter()
{
Outlook.Application app = new Outlook.Application();
Outlook.Selection items = app.ActiveExplorer().Selection;
foreach(object mail in items) {
Outlook.MailItem im = (Outlook.MailItem)mail;
_projectName = im.Subject.Replace(":", "");
_startDate = im.CreationTime.Date.ToShortDateString();
Directory.CreateDirectory("temp");
foreach(Outlook.Attachment attach in im.Attachments) {
attach.SaveAsFile(AppDomain.CurrentDomain.BaseDirectory + @"temp\" + attach.FileName);
_files.Add(attach.FileName);
}
im.SaveAs(AppDomain.CurrentDomain.BaseDirectory + @"temp\" + im.Subject.Replace(":", "") + ".msg");
_files.Add(im.Subject.Replace(":", "") + ".msg");
}
}