I had my first outlook add-in developed,
I can see that debugging the add-in opens the outlook automatically, the issue i noticed that outlook takes about 20 sec to open when my add-in attached (as new menu with one button).
I thought it might be caused by the fact the im debugging my project!,
I published my add-in to my localhost, and then installed it using the click once thing, but still hangs on load
the outlookAddIn2.vsto file is used by outlook as my custom add-in, but when i saw the other add-ins all of them was dlls not vsto plus they dont hang up the outlook on start
What should I do to deploy my project as dll and yet not to freeze my outlook on startup?
Thank you in advance.
p.s.: eventually the add-in will be implemented in our intranet employees outlook accounts
EDIT:
namespace OutlookAddIn2
{
public partial class ThisAddIn
{
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
MyToolBar();
}
private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
{
}
Office.CommandBar mainMenuBar;
Office.CommandBarPopup oldMenuBar;
Office.CommandBarPopup myMenuBar;
Office.CommandBarButton myButton;
private void MyToolBar()
{
try
{
mainMenuBar = this.Application.ActiveExplorer().CommandBars.ActiveMenuBar;
oldMenuBar = (Office.CommandBarPopup)this.Application.ActiveExplorer().CommandBars.ActiveMenuBar.FindControl
(
Office.MsoControlType.msoControlPopup, missing, "Katakit", true,true
);
if (oldMenuBar != null)
oldMenuBar.Delete(true);
myMenuBar = (Office.CommandBarPopup)mainMenuBar.Controls.Add(
Office.MsoControlType.msoControlPopup,
missing, missing, missing, false);
if (myMenuBar != null)
{
// Add a button to the new toolbar.
myMenuBar.Caption = "Katakit";
myMenuBar.Visible = true;
myMenuBar.Tag = "Katakit";
myButton = (Office.CommandBarButton)myMenuBar.Controls.Add
(Office.MsoControlType.msoControlButton, missing, missing, missing, true);
myButton.Caption = "Pending Summary 2";
myButton.FaceId = 500;
myButton.Tag = "btnPendingSummary";
myButton.Visible = true;
}
}
catch (System.Exception ex)
{
System.Windows.Forms.MessageBox.Show("Error: " + ex.Message.ToString()
, "Error Message");
}
}
#region VSTO generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InternalStartup()
{
this.Startup += new System.EventHandler(ThisAddIn_Startup);
this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown);
}
#endregion
}
}
Probably you run into the "Check for publishers certificate revocation" bottleneck. It has nothing to do with Outlook, but with .net-assemblies running in an environment without proper internet access. See this entry in the Add-in Express forum, with a reference to this discussion. Either you can disable an IE setting, or try to verify the Internet access.
I are always running myself into this problem when my VMWare development machine thinks it has network access, but the host's network is switched off, e.g. the VM is bridged to the host, but the network cable of the host is not plugged in, or if the VMWare guest is part of a domain with a domain controller running (=> network available), but this network has no Internet access and no proper Certificate Authority. In this case, slow startup time. If the host has Internet access, no startup delay.
Related
This copy button functionality is working in localhost. But when deploy it into server it's not working on server side.
protected void btnCopy_Click(object sender, EventArgs e)
{
try
{
Thread myth;
myth = new Thread(new System.Threading.ThreadStart(CallSaveDialog));
myth.ApartmentState = ApartmentState.STA;
myth.Start();
lblok.Text = "URL Copied to Clipboard, Use CTRL+V to Paste";
}
catch (Exception ex)
{
Class_login abc = new Class_login();
abc.writeerrorlog(ex.Message);
}
}
void CallSaveDialog() { System.Windows.Forms.Clipboard.SetText(TxtUrl.Text); }
This code:
System.Windows.Forms.Clipboard.SetText(TxtUrl.Text);
Runs on the web server. It sets the text to the clipboard of the user executing your web application, which usually is someone named IIS AppPool\Sitename. This user is not the visitor of your website, it is the server process that is running your .NET code.
It works on your development machine ("localhost"), because IIS Express runs as your user.
The solution is to do this using JavaScript: How do I copy to the clipboard in JavaScript?
Long time ago I made small AddIn for Excel to upload small trunks off data to SQL server. Quite simple form is called from context menu on right btn mouse click. It worked well on Win7 + Excel 2010 (don't know if OS is important). Recently I moved to Win10 + Excel 2013. And the context menu won't show up anymore... Well actually I can make it show but only once. My ThisAddIn_Startup
private void ThisAddIn_Startup(object sender, EventArgs e)
{
logger.Info("Started");
CreateContextMenu();
Application.SheetBeforeRightClick += Application_SheetBeforeRightClick;
}
And here's CreateContextMenu
private void CreateContextMenu()
{
try
{
Office.MsoControlType menuItem = Office.MsoControlType.msoControlButton;
uploadToDatabase = (Office.CommandBarButton)Application.CommandBars["Cell"].
Controls.Add(menuItem, missing, missing, 1, true);
uploadToDatabase.Style = Office.MsoButtonStyle.msoButtonCaption;
uploadToDatabase.Caption = "Upload to database";
uploadToDatabase.Tag = "0";
//MessageBox.Show("MF");
logger.Info("Added context menu");
}
catch (Exception ex)
{
logger.Error(ex);
}
}
In log file I see both records - "Started" and "Added context menu", but context menu is still not customized.
But if I uncomment the line MessageBox.Show("MF"); then it will show up for the first start of excel and then again dissappear if I close a workbook and open any other.
Does anyone have an idea why?
Appreciate for any hints.
The fact is that Command bars are not used any longer (were deprecated). The only possible way to customize the context menus in Office 2013 and later versions is to use the Fluent UI (aka Ribbon UI). You can read more about that in the following articles in MSDN:
Customizing Context Menus in Office 2010
Customizing the 2007 Office Fluent Ribbon for Developers (Part 1 of 3)
Customizing the 2007 Office Fluent Ribbon for Developers (Part 2 of 3)
Customizing the 2007 Office Fluent Ribbon for Developers (Part 3 of 3)
I am creating outlook add ons. I want when mail come inbox then change
the label, i use Outlook.ItemsEvents_ItemAddEventHandler(callBack)
method but in work only when outlook web app open. I want
Outlook.ItemsEvents_ItemAddEventHandler(callBack) call everytime
when mail comes in Inbox.
If there is ant Outlook Rest Api available for that problem.
private void Phishing_Load(object sender, RibbonUIEventArgs e)
{
outlookApp = new Outlook.Application();
inboxFolder = outlookApp.ActiveExplorer().Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox);
deleterFolder = outlookApp.ActiveExplorer().Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderJunk);
mailItems = inboxFolder.Items;//.Restrict("[Unread]=true");
mailItems.Sort("[ReceivedTime]", true);
inboxFolder.Items.ItemAdd += new Outlook.ItemsEvents_ItemAddEventHandler(CallFunction);
}
private void CallFunction(object data)
{
MessageBox.Show("call function");
}
Outlook add-in can work only when Outlook application is running. It seems you can't get what you wish using an Outlook add-in - find an alternative way. If you run Outlook against on-site Exchange server try to create a so called transport agent for Exchange.
I'm currently running in to an issue where a Windows Service I wrote is "timing out" instantly on start up. The message I get is Error 1053: The service did not respond to the start or control request in a timely fashion. I checked Event Viewer and I see that message and another A timeout was reached (30000 milliseconds) while waiting for the X service to connect. Only problem is that it's not waiting 30 seconds to time out, it's more like half a second.
My service's OnStart()
private static readonly ILog log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private string version = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).FileVersion;
private string incomingProdFileLocation = ConfigurationManager.AppSettings["ProdIncomingFileLocation"];
private string incomingCertFileLocation = ConfigurationManager.AppSettings["CertIncomingFileLocation"];
//private string incomingCombFileLocation = ConfigurationManager.AppSettings["CombIncomingFileLocation"];
private string processedFileLocation = ConfigurationManager.AppSettings["ProcessedFileLocation"];
private string errorFileLocation = ConfigurationManager.AppSettings["ErrorFileLocation"];
FileSystemWatcher prodWatcher = new FileSystemWatcher();
FileSystemWatcher certWatcher = new FileSystemWatcher();
//FileSystemWatcher combWatcher = new FileSystemWatcher();
protected override void OnStart(string[] args) {
log.InfoFormat("Starting up Merchant Bulk Load Service v{0}", version);
if (verifyDirectories()) {
log.InfoFormat("Initialize Prod FileSystemWatcher() at {0}", incomingProdFileLocation);
prodWatcher.Path = incomingProdFileLocation;
prodWatcher.Filter = "*.csv";
prodWatcher.Created += ProdBulkLoadFileReceived;
prodWatcher.EnableRaisingEvents = true;
log.InfoFormat("Initialize Cert FileSystemWatcher() at {0}", incomingCertFileLocation);
certWatcher.Path = incomingCertFileLocation;
certWatcher.Filter = "*.csv";
certWatcher.Created += CertBulkLoadFileReceived;
certWatcher.EnableRaisingEvents = true;
/*log.InfoFormat("Initialize Comb FileSystemWatcher() at {0}", incomingCombFileLocation);
combWatcher.Path = incomingCombFileLocation;
combWatcher.Filter = "*.csv";
combWatcher.Created += CombBulkLoadFileReceived;
combWatcher.EnableRaisingEvents = true;*/
} else {
log.ErrorFormat("verifyDirectories() returned false. Service stopping");
this.Stop();
}
}
private bool verifyDirectories() {
// verify each of the necessary directories exists before setting up any FileSystemWatcher()s
if (!Directory.Exists(incomingProdFileLocation)) {
log.ErrorFormat("Incoming production file location {0} does not exist. Please create the directory or edit the configuration file.",
incomingProdFileLocation);
return false;
}
if (!Directory.Exists(incomingCertFileLocation)) {
log.ErrorFormat("Incoming cert file location {0} does not exist. Please create the directory or edit the configuration file.",
incomingCertFileLocation);
return false;
}
/*if (!Directory.Exists(incomingCombFileLocation)) {
log.ErrorFormat("Incoming combined file location {0} does not exist. Please create the directory or edit the configuration file.",
incomingCombFileLocation);
return false;
}*/
if (!Directory.Exists(processedFileLocation)) {
log.ErrorFormat("Processed file location {0} does not exist. Please create the directory or edit the configuration file.",
processedFileLocation);
return false;
}
if (!Directory.Exists(errorFileLocation)) {
log.ErrorFormat("Error file location {0} does not exist. Please create the directory or edit the configuration file.",
errorFileLocation);
return false;
}
return true;
}
My entire service works splendidly in our development and certification environments, but won't start in our production environment, it doesn't seem like it's even getting to the OnStart() because a log is never made. Things I've checked:
Made sure service had correct permissions in the necessary directories, it does
Made sure the correct version of .NET framework that my service is targeting (4) is installed, it is
Made sure Event Viewer wasn't throwing any other types of errors that might give me a hint to what's happening, there's nothing
All of the directories for the FileSystemWatcher actually exist, they do
The directory for the log4net file exists, it does
I'm at a loss at the moment; any help would be awesome.
edit
After double checking the .NET framework again I realize I checked the wrong server for the versions. A good way to be certain is to double-click on the actual exe file for the service and see what it says. In my case it literally said "Make sure 4.0 is installed" which prompted me to check again and there I saw that 4.0 wasn't installed.
Are you sure that your .net is up to date. This could happen if for instance 3.5 is on the machine and you're using 4.0.
This is an old ticket, but I just saw the same error (albeit with "90000 milliseconds" rather than 30000) on all of the Windows services we've created as part of our application (about 10 of them). .Net framework was installed and functional.
I examined the registry setting where this 90000 ms (90 second) limit was set.
In the node, HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control
The value of ServicesPipeTimeout was 90000 (Decimal).
I didn't need it to be 90000 and I don't know why it was set thus, but it certainly wasn't waiting 90 seconds -- it was failing instantly.
So I modified the value to 30000 and rebooted the server.
All services begin starting or restarting successfully.
I need to play PowerPoint slides but first I want to check whether PowerPoint or viewer is installed on the machine or not. How can I do that using .NET?
It depends on whether you are trying to tell whether you can view a presentation (*.ppt, *.pptx, etc) or whether you can access the PowerPoint object model.
To check whether there is an associated handler for ppt files, you can do the following:
// using Microsoft.Win32;
private bool CheckPowerPointAssociation() {
var key = Registry.ClassesRoot.OpenSubKey(".ppt", false);
if (key != null) {
key.Close();
return true;
}
else {
return false;
}
}
if (CheckPowerPointAssociation()) {
Process.Start(pathToPPT);
}
To check whether the PowerPoint COM object model is available, you can check the following registry key.
// using Microsoft.Win32;
private bool CheckPowerPointAutomation() {
var key = Registry.ClassesRoot.OpenSubKey("PowerPoint.Application", false);
if (key != null) {
key.Close();
return true;
}
else {
return false;
}
}
if (CheckPowerPointAutomation()) {
var powerPointApp = new Microsoft.Office.Interop.PowerPoint.Application();
....
}
Note, however, that in both cases it will only give you a pretty good indication of the availability of PowerPoint. For example, an uninstallation may not have fully removed all traces. Also in my experience selling an Outlook addin for years I've seen certain antivirus programs that interfere with the COM object model in a screwup effort to protect against malicious scripts. So in any case, have robust error handling as well.
Hope this helps!
HKEY_CLASSES_ROOT\MSPowerPoint\protocol\StdFileEditing\server
This key is the same for all installs of PowerPoint and points to the install dir for the executable to run PowerPoint. Great to use when detecting if this product is installed and good for figuring out which folder Office products are installed in, when the install is not using the defaults.
I am not sure this is the right way to do this. But you can use this
try
{
//It will throw a WIN32 Exception if there is no associated
//application available to open the file.
Process p = Process.Start("C:\\Sample.pptx");
}
catch (Win32Exception ex)
{
MessageBox.Show("Powerpoint or Powerpoint viewer not installed\n");
}
What about checking if the EXE file for PowerPoint or PowerPoint viewer exists or not by using "Exists Method" from system.io namespace?
Check this.