I'm trying an ASP.NET App and I have a problem with OutLook.
Code behind :
OutlookApplication = new Application();
NameSpace nameSpace = OutlookApplication.GetNamespace("MAPI");
nameSpace.Logon("", "", missing, missing);
nameSpace = null;
When I play the app with Visual Studio it's ok.
When I play the app with IIS then :
System.UnauthorizedAccessException: Retrieving the COM class factory for >component with CLSID {000209FF-0000-0000-C000-000000000046} failed due to the >following error: 80070005 Access is denied. (Exception from HRESULT: 0x80070005 >(E_ACCESSDENIED)).
I already tried to change DCOM Configuration for "OutLook Message Attachment" with :
Proprieties -> Identity -> Execute user
Proprieties -> Security -> all kind of acces autorized for "everybody".
NB : I have no problem with others Office programm (Excel and Word).
I'm trying an ASP.NET App and I have a problem with OutLook.
Microsoft does not currently recommend, and does not support, Automation of Microsoft Office applications from any unattended, non-interactive client application or component (including ASP, ASP.NET, DCOM, and NT Services), because Office may exhibit unstable behavior and/or deadlock when Office is run in this environment.
If you are building a solution that runs in a server-side context, you should try to use components that have been made safe for unattended execution. Or, you should try to find alternatives that allow at least part of the code to run client-side. If you use an Office application from a server-side solution, the application will lack many of the necessary capabilities to run successfully. Additionally, you will be taking risks with the stability of your overall solution. Read more about that in the Considerations for server-side Automation of Office article.
As a workaround you may consider using a low-level API on which Outlook is based on (Extended MAPI) or any third-party wrappers around that API, for example, Redemption.
Related
In our organisation a problem occurs when saving Excel files.
Whenever we close a file there is a 50/50 chance that it saves in the location it was already in, but the other times it saves where another file was last saved.
We are all working on a Terminal Server (Windows 2019) using Office 2019.
Did anyone else stumble upon this as well? And perhaps found a solution?
The Considerations for server-side Automation of Office article states the following:
Microsoft does not currently recommend, and does not support, Automation of Microsoft Office applications from any unattended, non-interactive client application or component (including ASP, ASP.NET, DCOM, and NT Services), because Office may exhibit unstable behavior and/or deadlock when Office is run in this environment.
If you are building a solution that runs in a server-side context, you should try to use components that have been made safe for unattended execution. Or, you should try to find alternatives that allow at least part of the code to run client-side. If you use an Office application from a server-side solution, the application will lack many of the necessary capabilities to run successfully. Additionally, you will be taking risks with the stability of your overall solution.
I'd suggest using the Open XML SDK instead if you deal with open XML documents only, see Welcome to the Open XML SDK 2.5 for Office for more information.
I have a Windows service filling cells in an Excel Workbook via OLE Automation.
The save process is not working, the file is never saved. But when done in a GUI app, the save process works.
The service user is an administrator account. I suspect the interaction with the Desktop.
Any idea?
Don't do this. Find another solution. Microsoft does not support or recommend OLE automation of Office software from anywhere but a workstation desktop session. I can't paraphrase any better than what they say directly, so here's the advice (link above goes into more detail) :
All current versions of Microsoft Office were designed, tested, and configured to run as end-user products on a client workstation. They assume an interactive desktop and user profile. They do not provide the level of reentrancy or security that is necessary to meet the needs of server-side components that are designed to run unattended.
Microsoft does not currently recommend, and does not support, Automation of Microsoft Office applications from any unattended, non-interactive client application or component (including ASP, ASP.NET, DCOM, and NT Services), because Office may exhibit unstable behavior and/or deadlock when Office is run in this environment.
If you are building a solution that runs in a server-side context, you should try to use components that have been made safe for unattended execution. Or, you should try to find alternatives that allow at least part of the code to run client-side. If you use an Office application from a server-side solution, the application will lack many of the necessary capabilities to run successfully. Additionally, you will be taking risks with the stability of your overall solution.
If you need your service to store data, a database is probably a good choice. Any users that require the data in an excel spreadsheet could populate their documents from the database. You could even set up template documents to do this automatically.
I had the same problem, run a Delphi software as service, with an administrator user and it gave to me a lot of errors in the read/write process like SaveAs method of Workbook class failed
The solution for read/save was create both folders below:
C:\Windows\System32\config\systemprofile
C:\Windows\SysWOW64\config\systemprofile\
There isn't much sense at all, but it worked.
I am trying to us ILMerge via nuget to merge two SharePoint assemblies in to my plugin dll. The assemblies are;
Microsoft.SharePoint.Client (v16.1)
Microsoft.SharePoint.Client.Runtime (v16.1)
They seem to successfully merge in to my single plugin dll and i can see the required classes etc if I inspect the dll with JustDecompile.
When debugging the plugin, it throws a security exception;
Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=4.0.0.0
The code successfully steps over the creation of 'ClientContext()' which is located in the Microsoft.SharePoint.Client dll, but then fails when it reaches the 'new SharePointCredentials()' line which is held in the Microsoft.SharePoint.Client.Runtime dll.
using (var srcContext = new ClientContext(url))
{
srcContext.Credentials = new SharePointOnlineCredentials(username, securePassword);
I am stuck as to why this might be happening. It is Dynamics 365 online and SharePoint online. The credentials supplied to the constructor are correct. Any pointers would be greatly appreciated. I really don't want to have to create a web service instead of ILMerging the SharePoint dlls.
This is almost undoubtedly related to the to the method being called requiring permissions that Dynamics 365 Online does not allow. That is usually the cause of a System.Security.Permissions.SecurityPermission error in a Plugin/Workfrom running in Dynamics 365 Online.
It's been a longtime, but if memory serves me correctly the SharePoint client libraries do not work in Dynamics 365 sandbox plugins (and all online plugins are in the sandbox.)
Unless you can find a way to make the calls without the libraries, using the SharePoint REST API, you'll have to either create a web service or (in my opinion the preferable if possible solution is to) use Azure Service Bus to handle the execution.
As Nick says, unfortunatelly Sharepoint.client.dll will throw you a “System.Security.SecurityException: That assembly does not allow partially trusted callers” error even if you use ILMerge to deploy it.
It is a limitation from Sandbox and there is nothing we can do until Microsoft deals with this.
But for the time being, the best way is to do oldschool httprequests as explained here: https://code.msdn.microsoft.com/SharePoint-Integration-c5f21604
Good Luck!
Is it posible to create outlook meeting on Sharepoint page behalf on current sharepoint user?
I try to create meeting by button click with next code
Application oApp = new Microsoft.Office.Interop.Outlook.Application();
AppointmentItem appointment = (AppointmentItem)oApp.CreateItem(OlItemType.olAppointmentItem);
appointment.Start = DateTime.Now.AddHours(1);
appointment.End = DateTime.Now.AddHours(2);
appointment.Subject = "Some subject";
appointment.Body = "Some body";
appointment.Recipients.Add("user1#somemail.com");
appointment.Recipients.Add("user2#somemail.com");
appointment.Save();
But i get this error, on calling appointment.Recipients
Operation aborted (Exception HRESULT: 0x80004004 (E_ABORT))
When i run this code in console application it works fine. Any ideas?
Thanks in advance
The Considerations for server-side Automation of Office article states the following:
Microsoft does not currently recommend, and does not support, Automation of Microsoft Office applications from any unattended, non-interactive client application or component (including ASP, ASP.NET, DCOM, and NT Services), because Office may exhibit unstable behavior and/or deadlock when Office is run in this environment.
If you are building a solution that runs in a server-side context, you should try to use components that have been made safe for unattended execution. Or, you should try to find alternatives that allow at least part of the code to run client-side. If you use an Office application from a server-side solution, the application will lack many of the necessary capabilities to run successfully. Additionally, you will be taking risks with the stability of your overall solution.
If you deal with Exchange profiles, you may consider using EWS (Exchange Web Services). See EWS Managed API, EWS, and web services in Exchange for more information.
I am wondering if it is possible to pass data from an ASP.NET MVC controller to Microsoft Word 2013 Template, using an instantiated Host Item, and bind it to content controls within the template.
Ideally I would like to pass the data to the ThisDocument class and have the data applied to the template's databindings, however I cannot find how to instantiate and use the ThisDocument object after I have created an interop instance of the Word template.
Microsoft does not currently recommend, and does not support, Automation of Microsoft Office applications from any unattended, non-interactive client application or component (including ASP, ASP.NET, DCOM, and NT Services), because Office may exhibit unstable behavior and/or deadlock when Office is run in this environment.
If you are building a solution that runs in a server-side context, you should try to use components that have been made safe for unattended execution. Or, you should try to find alternatives that allow at least part of the code to run client-side. If you use an Office application from a server-side solution, the application will lack many of the necessary capabilities to run successfully. Additionally, you will be taking risks with the stability of your overall solution. You can read more about that in the Considerations for server-side Automation of Office article.
Consider using the Open XML SDK, see Welcome to the Open XML SDK 2.5 for Office for more information. Or any other third-party components designed for the server-side execution.