I am using watin framwork. I have wrote code ie.Runscript('newnote()'); Its running in my pc IIS success. This code also runnign with client visual studio 2008 with success but failed with client IIS. I have also set all rights in IIS and web folder. also check with IE7 and IE8. We have verfied with SSL certificate.But we can not identify where is problem.
please, help me.
Error: (1) Run script failed. and some time (2)Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
Code Like:
string mfnQS='45SDS82'
string noteURL = string.Format ("https://sitename.co.uk/apps/shared/dlg_addnoteform.jsp?{0}&parent_package=cxa&cid=", mfnQS);
ie.GoTo(noteURL);
ie.WaitForComplete(2000);
Thread.Sleep(2000);
objBO.NoteDetails = objBO.NoteDetails;
string sNote = StringUtility.RemoveHtmlTag(objBO.NoteDetails);
TextField notetext = ie.TextField(Find.ById("notetext"));
notetext.WaitUntilExists(2000);
notetext.Value = sNote;
notetext.WaitForComplete();
ie.RunScript("$('iframe').contents().find('html body').html(document.addnote.notetext.value)");
WatiN.Core.Button btnAdd = ie.Button(Find.ByValue("ADD NOTE"));
if (btnAdd.Exists)
{
if (ClsReadOnlyKeyword.IsFinalVersion)
{
ie.RunScript("newnote();");
Thread.Sleep(2000);
isTrue = true;
}
}
Related
I am using below code in the button event, so that user can send mail through self machine outlook directly (nuget Microsoft. Office. Interop.Outlook). Code is working when I am debugging below code in my localhost and send mail from outlook. But problem is when I deployed the code into web server and browse through IE from my work station, mail not send through outlook.
This error message show in log:
Retrieving the COM class factory for component with CLSID {0006F03A-0000-0000-C000-000000000046} failed due to the following error: 80070005 Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)).
How can I resolve this issue?
Web application reside into web server and users will access the application from IE and then they will send mail through self machine outlook.
public void SendEmailOutlook(string mailToRecipients, string mailCCRecipients, string subjectLine, [Optional] string attachments, string HTMLBody)
{
try
{
Microsoft.Office.Interop.Outlook.Application oApp = new Microsoft.Office.Interop.Outlook.Application();
Microsoft.Office.Interop.Outlook.MailItem oMsg = oApp.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem);
Outlook.Recipients oRecips = oMsg.Recipients;
List<string> oTORecip = new List<string>();
List<string> oCCRecip = new List<string>();
var ToRecip = mailToRecipients.Split(',');
var CCRecip = mailCCRecipients.Split(',');
foreach (string ToRecipient in ToRecip)
{
oTORecip.Add(ToRecipient);
}
foreach (string CCRecipient in CCRecip)
{
oCCRecip.Add(CCRecipient);
}
foreach (string to in oTORecip)
{
Outlook.Recipient oTORecipt = oRecips.Add(to);
oTORecipt.Type = (int)Outlook.OlMailRecipientType.olTo;
oTORecipt.Resolve();
}
foreach (string cc in oCCRecip)
{
Outlook.Recipient oCCRecipt = oRecips.Add(cc);
oCCRecipt.Type = (int)Outlook.OlMailRecipientType.olCC;
oCCRecipt.Resolve();
}
oMsg.Subject = subjectLine;
if (attachments.Length > 0)
{
string sDisplayName = "MyAttachment";
int iPosition = 1;
int iAttachType = (int)Outlook.OlAttachmentType.olByValue;
var Sendattachments = attachments.Split(',');
foreach (var attachment in Sendattachments)
{
Outlook.Attachment oAttach = oMsg.Attachments.Add(attachment, iAttachType, iPosition, sDisplayName);
}
}
if (HTMLBody.Length > 0)
{
oMsg.HTMLBody = HTMLBody;
}
oMsg.Save();
oMsg.Send();
oTORecip = null;
oCCRecip = null;
oMsg = null;
oApp = null;
}
catch (Exception e)
{
//print(e.Message);
}
}
Outlook, just like every other Office app, cannot be used from a service (such as IIS).
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.
As a possible workaround you may consider using EWS or any other REST API (for example, Graph API) if you deal with Exchange server profiles only. See Explore the EWS Managed API, EWS, and web services in Exchange for more information.
I've had this issue too."Retrieving the COM class factory for component with CLSID {0006F03A-0000-0000-C000-000000000046} failed due to the following error: 80070005 Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))."
Server environment:Windows server 2019&iis
Local machine:Windows 10&iis
Tip:The Microsoft office doesn't support that use OutWork IIS or Asp.net
So,I give you right answer(It's worked):
1、Run "win+R" ,then inuput 'Dcomcnfg'
2、As this pic:
enter image description here
I have been working on an issue for the past 2 days.I have tried to debug in every way possible but in vain.
Everything works fine on my local.But on production this fails.
Here is a brief description about the problem.
I have a download button and when I click that button I intend to download a file from a server.
protected void Download_Click(object sender, EventArgs e)
{
Button downloadButton = sender as Button;
string filePath = downloadButton.CommandArgument;
string stuid = Session["browse_files_for_student"].ToString();
string stuUsername = MyHelper.GetUsernameForStudentID(stuid);
MyHelper.LogAccess(User.Identity.Name, StudentUsername.Text, filePath, MyHelper.LogAccessType.Read);
FileInfo file = new FileInfo(filePath);
// Download the file
Response.Clear();
Response.AppendHeader("content-disposition", "attachment; filename=" + file.Name);
try
{
Response.TransmitFile(filePath);
}
catch (IOException error)
{
Response.Cookies.Add(new HttpCookie("global_last_error", "The file is in use by another process."));
Response.Redirect("~/Public/KnownError.aspx");
}
Response.End();
}
I see on the Event Viewer that it generates:
TransmitFile failed:FileName:dsdfsfd.doc,Impersonation Enabled:0,Token Valid:1 HRESULT:0x8007052e.
Environment: The website is deployed on a Windows 2000 server.
Any help and comments would be appreciated.
Thank you.
The account under which your application is running (probably IIS pool account) does not have access to the file that you are trying to send. The error code 0x8007052e means:
Error code: (HRESULT) 0x8007052e (2147943726) - Logon failure: unknown user name or bad password.
In the future you can check the error code using for instance cdb command (cdb is a part of the freely available Windows Debugging Tools):
cdb notepad.exe
And then after it has started:
0:000> !error 0x8007052e
Error code: (HRESULT) 0x8007052e (2147943726) - Logon failure: unknown user name or bad password.
Hope it helps :)
I'm writing an OPC client that connects to a remote server and reads data etc. I am using advosol's BGServer class. The issue is, when I run the program in visual studio I get the following error on adding a group.
"Exception from HRESULT: 0x80040202"
My problem is similar to (http://stackoverflow.com/questions/5978721/opc-server-access-remotely-using-opcda-net-tools), however, I know the DCom settings are configured correctly because when I run the same code by double clicking the .exe I connect and can add a group with no problems.
Therefore I'm guessing that visual studio is running under some strange user/group, and screws up the dcom permissions (mainly with callbacks).
edit: code
BGServer server;
private void Form1_Load(object sender, EventArgs e)
{
server = new BGServer(this);
server.Connect(new OPC.Common.Host() { HostName = "xp-devbox2", UserName = "OPCUser", Password = "OPCUser" }, "FactoryTalk Gateway", null, ServerConnected);
}
void ServerConnected(BGException ex, object tag)
{
if (ex != null)
{
label1.Text = ex.Message;
}
else
{
//we've connected to the server. let's start subscribing to stuff!
server.AddGroup("Tuner DataGroup", true, 1000, 0, null, null, new OnBGSrvAddGroup(GroupAdded));
}
}
private BGGroup dGroup;
void GroupAdded(BGException ex, BGGroup group, object tag)
{
if (ex != null)
{
label1.Text = ex.Message;
}
else label1.Text = "Group Added";
}
Are you using reg-free COM to communicate with the OPC? When you use the "Visual Studio Hosting Process" any external ".exe.manifest" files that you create the do reg-free COM will not be carried into the manifest of the vshost.exe process.
I've written an outlook plugin that retrieves the sender's SMTP email address for a mailitem. It is working fine on most machines, however, I have one machine (my new development machine) that throws a COMException every time it tries to resolve the SMTP address for an email from an exchange user. Below is the code I'm using...
private string SenderEmail(MailItem item)
{
if (item == null)
{
return "";
}
else
{
string senderEmail = string.Empty;
if (item.SenderEmailType.ToUpper() == "EX")
senderEmail = GetEmailAddressFromOU(item.SenderEmailAddress);
else
senderEmail = item.SenderEmailAddress;
return senderEmail;
}
}
private string GetEmailAddressFromOU(string ouName)
{
string emailAddress = string.Empty;
NameSpace oNS = ((Microsoft.Office.Interop.Outlook.Application)OutlookAppObj).GetNamespace("MAPI");
Recipient recip = oNS.CreateRecipient(ouName);
recip.Resolve();
ExchangeUser exUser = recip.AddressEntry.GetExchangeUser();
emailAddress = exUser.PrimarySmtpAddress;
Marshal.ReleaseComObject(exUser);
Marshal.ReleaseComObject(recip);
Marshal.ReleaseComObject(oNS);
return emailAddress;
}
The following COMException occurs when accessing the AddressEntry property of the Recipient object:
Message = "The attempted operation failed. An object could not be found."
I'm using Windows 7 (64bit), using Outlook 2010, however this same code works on other machines with the same OS and Outlook version. It also works fine on my previous development machine which was also Windows 7 (32bit) and Outlook 2010.
I've searched StackOverflow and Google for any resolution, but haven't found any.
Can anyone shed some light on this problem?
Still not sure what was causing the problem, but deleting all my E-Mail accounts in Outlook and re-adding them, fixed the problem.
To fix account problems try deleting the OST file.
This link explains how to do it:
http://social.technet.microsoft.com/Forums/en/w7itprogeneral/thread/d8fe1d52-4f95-4158-ab2f-13cab5cbabf9
I am facing a curious problem:
I am trying to build a Add-In for Outlook 2002 with Visual Studio 2008 using the shared add-in template.
I want a simple hello world within the OnStartUpComplete method.
That works pefectly on my development machine, but not at all on a clean machine with outlook 2002.
I used the generated setup project to install the add in.
Load behavior changed back from 3 to 2 after starting outlook, but there neither comes an exception nor any other error.
What do I have to do to get the Add-In working on other than the dev machine?
Thanks a lot,
Michael
i believe your are a lockback policy victim.
add a bypass key to registry, then it works. modern office versions or vsto creates the key while installation. the effect is: install a modern office too and the adddin now are also loaded in older office. please take a look
code snippet taken from NetOffice http://netoffice.codeplex.com
public static void RegisterFunction(Type type)
{
try
{
// add codebase value
Assembly thisAssembly = Assembly.GetAssembly(typeof(ExampleClassicAddin));
RegistryKey key = Registry.ClassesRoot.CreateSubKey("CLSID\\{" + type.GUID.ToString().ToUpper() + "}\\InprocServer32\\1.0.0.0");
key.SetValue("CodeBase", thisAssembly.CodeBase);
key.Close();
key = Registry.ClassesRoot.CreateSubKey("CLSID\\{" + type.GUID.ToString().ToUpper() + "}\\InprocServer32");
key.SetValue("CodeBase", thisAssembly.CodeBase);
key.Close();
// add bypass key
// http://support.microsoft.com/kb/948461
key = Registry.ClassesRoot.CreateSubKey("Interface\\{000C0601-0000-0000-C000-000000000046}");
string defaultValue = key.GetValue("") as string;
if (null == defaultValue)
key.SetValue("", "Office .NET Framework Lockback Bypass Key");
key.Close();
// add addin key
Registry.ClassesRoot.CreateSubKey(#"CLSID\{" + type.GUID.ToString().ToUpper() + #"}\Programmable");
Registry.CurrentUser.CreateSubKey(_addinRegistryKey + _prodId);
RegistryKey rk = Registry.CurrentUser.OpenSubKey(_addinRegistryKey + _prodId, true);
rk.SetValue("LoadBehavior", Convert.ToInt32(3));
rk.SetValue("FriendlyName", _addinName);
rk.SetValue("Description", "NetOffice COMAddinExample with classic UI");
rk.Close();
}
catch (Exception ex)
{
string details = string.Format("{1}{1}Details:{1}{1}{0}", ex.Message, Environment.NewLine);
MessageBox.Show("An error occured." + details, "Register " + _addinName, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}