Hi Friends,
In my application i need to send email notification when the form is submitted. here i wrote code in the button click event. my problem is it is working when i tested in the server, but when the form is submitted in the client mechine means after publishint to sharepoint library it is promting with the error message.
here is my code
MailMessage mailMsg=new MailMessage();
thisXDocument.UI.Alert("Hi");
mailMsg.From = "
[email protected]";
//thisXDocument.UI.Alert(strReportingToMailId.text);
mailMsg.To = mail.text; //strReportingToMailId.text;
//mailMsg.Cc =strInitiatedUserMailId.text;
mailMsg.Subject = "sending the mail when the button is clicked";
mailMsg.BodyFormat = MailFormat.Html;
//mailMsg.Body = nv.Body ;
SmtpMail.Send( mailMsg );
thisApplication.ActiveWindow.Close(true);
the error message i am getting is
Request for the permission of type 'System.Web.AspNetHostingPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
at System.Security.CodeAccessSecurityEngine.ThrowSecurityException(Assembly asm, PermissionSet granted, PermissionSet refused, RuntimeMethodHandle rmh, SecurityAction action, Object demand, IPermission permThatFailed)
at System.Security.CodeAccessSecurityEngine.ThrowSecurityException(Object assemblyOrString, PermissionSet granted, PermissionSet refused, RuntimeMethodHandle rmh, SecurityAction action, Object demand, IPermission permThatFailed)
at System.Security.CodeAccessSecurityEngine.CheckSetHelper(PermissionSet grants, PermissionSet refused, PermissionSet demands, RuntimeMethodHandle rmh, Object assemblyOrString, SecurityAction action, Boolean throwException)
at System.Security.CodeAccessSecurityEngine.CheckSetHelper(CompressedStack cs, PermissionSet grants, PermissionSet refused, PermissionSet demands, RuntimeMethodHandle rmh, Assembly asm, SecurityAction action)
at SendMail.SendMail.Button_OnClick(DocActionEvent e)
at Microsoft.Office.Interop.InfoPath.SemiTrust._ButtonEventSink_SinkHelper.OnClick(DocActionEvent pEvent)
Could any one please solve my problem?
thanks in advance...