I've created an VSTO-Add-In for Outlook, which imports several data from an pdf-file and saves the data as an MS-Excel-File. After successfully process i start a Toastnotification ,which enables an fast opening of this Excel-file by clicking on the notification in the info-center. The problem: clicking on the notification of other incoming e-mails (Outlook) doesn't work anymore. Nothing happens. How can i solve this problem?
public Ribbon1()
{
Initialize();
}
private async Task Initialize()
{
await Task.Run(() =>
{
ToastNotificationManagerCompat.OnActivated += async toastArgs =>
{
ToastArguments args = ToastArguments.Parse(toastArgs.Argument);
await Task.Run(() =>
{
if (!string.IsNullOrEmpty(toastArgs.Argument) && !toastArgs.Argument.Contains("idEPST=ignore") && toastArgs.Argument.Contains("idEPST="))
{
string datei = toastArgs.Argument.ToLower().Replace("idEPST=", String.Empty).Trim().Replace(".xls", "");
ProcessStartInfo si = new ProcessStartInfo();
si.FileName = "excel.exe";
si.Arguments = $"\"C:\\folder\\file.xls\" /{datei}";
Process.Start(si);
}
});
};
});
}
}
//and later
new ToastContentBuilder()
.AddAudio(null, silent: true)
.AddArgument("idEPST", filename)
.AddHeader("identifier", "My Excel App Name", String.Empty)
.AddText($"{name}, {firstname}", hintMaxLines: 1)
.AddText("... sucessfully saved.")
.Show();
After deinstalling the VSTO-Add-In: On clicking on a e-mail-notification results in an error message:
"Cannot Start Microsoft Outlook. The Command Line Argument Is Not Valid..."
It seems there are some problems with windows registry keys, especially with .msg file associations. Because when you click on a toast notification in Outlook a corresponding item is displayed/opened.
Re-associate the .msg file by following the steps and verify the results.
Click on Start and then Default Programs.
Click on Associate a file type protocol with a program option.
Select .msg from the Name list and then click on Change Program.
Now click to select Microsoft Office Outlook and then click on OK.
Restart the computer and then try opening emails saved on the Computer.
See Error: The command line argument is not valid. Verify the switch you are using. for more information.
Related
I am trying to build a simple app (As Console Application) that enters a Zoom meeting automatically at a specified time.
The app opens the Zoom meeting using Process.Start function, and then wait for the "Zoom Meeting" process to start.
It works well if I use a Windows shortcut file (.lnk extension) with the correct parameters, like shown here
But is doesn't work when I use the "regular" Zoom link (the url) because it opens the browser and waits for user input (It shows an alert).
I know how to send input to a process, so all I need is to a reference to the browser window that opened, but I can't find it.
The Process.Start doesn't return it and when I looped through all processes (Process.GetProcesses) I couldn't find any useful name that I can search for.
So, how can I get a reference to the browser process? Or at least send it input when it start.
Thanks in advance.
=== EDIT ===
After digging in Windows Registry, I have found an even simpler code to achieve it:
public static void OpenZoomMeeting(string link)
{
string zoomDirectory = Environment.ExpandEnvironmentVariables(#"%APPDATA%\Zoom\bin");
ProcessStartInfo startInfo = new ProcessStartInfo
{
FileName = $#"{zoomDirectory}\Zoom.exe",
Arguments = $"--url={link}",
WorkingDirectory = zoomDirectory
};
Process.Start(startInfo);
}
=== OLD CODE ===
Found the solution thanks to jdweng
He said that I should to use a WebBrowser to open the meeting without the prompt, so I looked into it.
Because my app is a Console Application, I can't just use a WebBrowser so I found That solution and it worked for me.
Thank you for your help
===The code===
private void RunBrowserThread(string url) {
var th = new Thread(() => {
var br = new WebBrowser();
br.DocumentCompleted += Browser_DocumentCompleted;
br.Navigate(url);
Application.Run();
});
th.SetApartmentState(ApartmentState.STA);
th.Start();
}
void Browser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) {
var br = sender as WebBrowser;
if (br.Url == e.Url) {
Console.WriteLine("Natigated to {0}", e.Url);
Application.ExitThread(); // Stops the thread
}
}
I am attempting to schedule a CefSharp rendering of pages stored in SharePoint via a SharePoint Timer Job. However, the OWSTIMER.exe service crashes almost immediately after calling Cef.Initialize(), throwing next to no errors.
The Subscription Class is:
internal class Subscriptions: IDisposable
{
internal Subscriptions()
{
db = // CreateConnection();
if (Cef.IsInitialized == false)
{
var settings = new CefSettings
{
CachePath = "cache",
BrowserSubprocessPath = "ProjectBin\\CefSharp.BrowserSubprocess.exe",
LogSeverity = LogSeverity.Default,
};
Cef.Initialize(settings);
}
}
internal void RunTodaysSubscriptions()
{
var subs = db.tt_ScheduledJobs.Where(sj => sj.Date <= DateTime.Today).Select(sj => sj.tt_Subscription).ToList();
foreach (var sub in subs)
{
ExecuteSubscription(sub);
SetNextSchedule(sub);
}
}
private void ExecuteSubscription(tt_Subscription subscription)
{
tt_JobHistory historyEntry = new tt_JobHistory();
historyEntry.SubscriptionKey = subscription.SubscriptionKey;
historyEntry.StartDate = DateTime.Now;
historyEntry.Status = "In Progress";
dfe.tt_JobHistory.Add(historyEntry);
dfe.SaveChanges();
string url = //path to file
using (SubscriptionExecution se = new SubscriptionExecution(
url,
subscription.SubscriptionKey,
subscription.Format))
{
//Completed represents either a response from the dashboard that the export either succeded
//or failed. If there is no response (i.e. a javascript error preventing the dashboard from executing
//an export, then we would hit the timeout of 5 minutes and shutdown this process.
if (SpinWait.SpinUntil(() => se.Completed == true, 120000) == true)
{
//Had a response from dashboard, could be a success or failure
if (se.ServerModel.Success == true) SuccessHistoryEntry(historyEntry);
else ErrorHistoryEntry(se.ServerModel.Message, historyEntry);
}
else
{
ErrorHistoryEntry("Process timed out generating subscription", historyEntry);
}
}
db.SaveChanges();
}
// ...
}
SubscriptionExecution is:
internal class SubscriptionExecution : IDisposable
{
// ...
internal SubscriptionExecution(string url, int subscriptionId, string fileType, string logLocation)
{
LogLocation = logLocation;
SubscriptionId = subscriptionId;
FileType = fileType;
Completed = false;
ServerModel = new ServerModel();
ServerModel.PropertyChanged += new PropertyChangedEventHandler(ServerModel_PropertyChanged);
browser = new ChromiumWebBrowser(url);
browser.RegisterJsObject("serverModel", ServerModel);
browser.LoadingStateChanged += LoadingStateChanged;
if (LogLocation != string.Empty) browser.ConsoleMessage += BrowserConsoleMessage;
}
private void ServerModel_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (e.PropertyName == "Success")
{
Completed = true;
}
}
// ...
}
There's a loadingStateChange function that injects some javascript that modifies the ServerModel.Success field when an event happens.
However, I can't seem to get this far. Except in one specific circumstance, the timerjob reaches the Cef.Initialize(settings) section, and then immediately restarts. Unfortunately, outside the event log, there is no error message to be found.
In the Windows Event Log, there is
which is indicating an error in libcef.dll
I've installed the libcef.dll.pdb symbols for this version of cefsharp (v57).
The CefSharp troubleshooting guide suggests that in instances like this, there should be logfiles or error dumps. There should be a file 'debug.log' in the folder with the executable, and perhaps a mini crashdump file in AppData\Local\CrashDumps.
However, as this is a SharePoint Timer job, these files don't seem to be appearing. I did find a debug.log file inside the 15 hive bin (C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\BIN); however this file is empty.
I can't find the CrashDumps folder anywhere; checked under all user accounts on the machine, especially the running account and the SharePoint Timer Job managed account.
The one specific circumstance that I can get the code to run without restarting the timer job is immediately after the server is restarted. Restarting the server has (temporarily) fixed a few other problems around this issue, and so I suspect it might be related. Namely, I have had trouble retracting and redeploying the farm solution. This throws a couple of different errors:
on retracting: <SERVER>: The process cannot access the file 'C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\BIN...\icudtl.dat' because it is being used by another process.
Error: The removal of this file failed: C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\BIN...\icudtl.dat.
on deploying: The requested operation cannot be performed on a file with a user-mapped section open.
I've attempted to find what other process is using icudtl.dat using Process Explorer, but all I could find was chrome, which was accessing a different copy. Killing all chrome processes and trying again also did not solve the problem.
I want to be able to open a PDF using the native Windows Reader Application when a user clicks on a button. So far I am able to use the following code to successfully open files that end with the (.PNG) extension. However, when I let the link to open the (.PDF) file I get the following error.
The system cannot find the file specified. (Exception from HRESULT: 0x80070002)
The file destination is correct.
Here is my code:
private async void btnLoad_Click(object sender, RoutedEventArgs e)
{
// Path to the file in the app package to launch
string imageFile = #"Data\Healthcare-Flyer.pdf";
var file = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync(imageFile);
if (file != null)
{
// Set the option to show the picker
var options = new Windows.System.LauncherOptions();
options.DisplayApplicationPicker = true;
// Launch the retrieved file
bool success = await Windows.System.Launcher.LaunchFileAsync(file, options);
if (success)
{
// File launched
}
else
{
// File launch failed
}
}
else
{
// Could not find file
}
}
}
When you add PDF document in project, you have to change it's build action.
Right click on PDF document.
Click on properties.
Change Build Action from None to Content
I have a app that when you click a button it opens a file that is on a SharePoint share. In IE it will open the document in word correctly that if you make changes to the file it will push the changes back to the SharePoint server, however if a user has Firefox as their default browser Firefox will download the file first then use the local copy. Is there a way to force the program to open the link in IE instead of the default browser (or to Word directly, however I need to pass the users domain credentials before I get access to the file)?
BackgroundWorker bw = new BackgroundWorker();
GeneratingChecklist frmProgressBar = new GeneratingChecklist();
frmProgressBar.Show();
bw.DoWork += (sender, e) =>
{
e.Result = Build(AccountNumber, PracticeName, ContractID, EducationDate, MainContactInfo, Address);
};
bw.RunWorkerCompleted += (sender, e) =>
{
frmProgressBar.Close();
running = false;
if (e.Result != null)
{
System.Diagnostics.Process.Start(((FileDetails)e.Result).Address);
}
else
{
MessageBox.Show("An error occurred generating or retrieving the educator checklist.");
}
};
bw.RunWorkerAsync();
FileDetails.Address contrains the url to the word document.
Try:
System.Diagnostics.Process.Start("iexplore.exe", "http://sp.path.to/your/file.doc")
See the MSDN documentation for more information about opening processes with arguments.
A while back I wrote a silverlight user control which had a csv import/export feature. This has been working fine, until recently I discovered it erroring in one scenario. This may have been due to moving to Silverlight 3.
The Error:
Message: Unhandled Error in Silverlight 2 Application
Code: 4004
Category: ManagedRuntimeError
Message: System.Security.SecurityException: Dialogs must be user-initiated.
at System.Windows.Controls.OpenFileDialog.ShowDialog()
at MyControl.OpenImportFileDialog()
at ...
The Code:
private void BrowseFileButton_Click(object sender, RoutedEventArgs e)
{
if (string.IsNullOrEmpty(lblFileName.Text))
{
if (MessageBox.Show("Are you sure you want to change the Import file?", "Import", MessageBoxButton.OKCancel) == MessageBoxResult.Cancel)
{
return;
}
}
EnableDisableImportButtons(false);
var fileName = OpenImportFileDialog();
lblFileName.Text = fileName ?? string.Empty;
EnableDisableImportButtons(true);
}
private string OpenImportFileDialog()
{
var dlg = new OpenFileDialog { Filter = "CSV Files (*.csv)|*.csv" };
if (dlg.ShowDialog() ?? false)
{
using (var reader = dlg.File.OpenText())
{
string fileName;
//process the file here and store fileName in variable
return fileName;
}
}
}
I can open an import file, but if i want to change the import file, and re-open the file dialog, it errors. Does anyone know why this is the case?
Also, I am having trouble debugging because placing a breakpoint on the same line (or prior) to the dlg.ShowDialog() call seems to cause this error to appear as well.
Any help would be appreciated?
You do two actions on one user click.
You show a messagebox which effectively uses your permission to show a dialog on user action.
You then try to show the dialog, since this is a second dialog on user action it's not allowed.
Get rid of the confirmation dialog and you'll be fine.
Remove Break Points before if (dlg.ShowDialog() ?? false) code will run its work for me.