Monday, 30 September 2013

Opening the Pop up page in SharePoint and refresh the parent after closing the Pop-up.

This function will open the new page in the Pop up window (ModalDialogBox) and when that is closed then the parent page will get refreshed. This is very similar to add new item in the list

<a onclick="OpenPopUpPage('http://SharePointPageLink', RefreshPage); return false;" href="">This will open the page in Pop up and will refresh the parent page when the Pop Up page is closed. < /a>
this is sharepoint Out of box Functionality.

we can also pass width and height of the window
say:
width =800;
height=500;
then 
<a onclick="OpenPopUpPage('http://SharePointPageLink', RefreshPage,800,500); return false;" href="">test it< /a>
hope this will help some one.

Friday, 6 September 2013

The remote certificate is invalid according to the validation procedure_Sendmail

//Sending Mail From Asp.net

             System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();
            mail.To.Add(to);
            mail.From = new MailAddress(from, from, System.Text.Encoding.UTF8);
            mail.Subject = "subject";
            mail.SubjectEncoding = System.Text.Encoding.UTF8;
            mail.BodyEncoding = System.Text.Encoding.UTF8;
            mail.IsBodyHtml = true;
            mail.Priority = MailPriority.High;
            
             mail.Body = "test mail";
            SmtpClient client = new SmtpClient();
            // this line will solve problem
            ServicePointManager.ServerCertificateValidationCallback = delegate(object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { return true; };
            client.Credentials = new System.Net.NetworkCredential("mail Id", "password");
            client.Port = 587;
            client.Host = "smtp.gmail.com";
            client.EnableSsl = true;
            try
            {
                client.Send(mail);
            }
            catch (Exception ex)
            {
                Exception ex2 = ex;
                string errorMessage = string.Empty;
                while (ex2 != null)
                {
                    errorMessage += ex2.ToString();
                    ex2 = ex2.InnerException;
                }
                
            } // end try