コード例 #1
0
        private void InsertUserIdAndCollegeId(int userId, int collegeId)
        {
            try
            {
                var errMsg    = "";
                var objCommon = new Common();
                var result    = objCommon.InsertUserIdAndCollegeId(userId, collegeId, out errMsg);

                if (result > 0)
                {
                    var objMailTemplete = new MailTemplates();

                    var objMail = new MailMessage
                    {
                        From    = new MailAddress(ApplicationSettings.Instance.Email),
                        Subject = "College Registration:" + txtCollegeName.Text.Trim()
                    };
                    var mailbody = objMailTemplete.MailToCollegeUser(txtCollegeContactPersonName.Text.Trim(),
                                                                     txtCollegeName.Text.Trim(),
                                                                     ddlState.SelectedItem.Text,
                                                                     ddlCity.SelectedItem.Text,
                                                                     txtCollegePhone.Text.Trim(),
                                                                     txtEmailId.Text.Trim(), txtMobile.Text.Trim());
                    objMail.Body = mailbody;
                    objMail.To.Add(txtEmailId.Text.Trim());
                    objMail.IsBodyHtml = true;
                    Utils.SendMailMessageAsync(objMail);

                    var objMail1 = new MailMessage
                    {
                        From    = new MailAddress(ApplicationSettings.Instance.Email),
                        Subject = "College Registration:" + txtCollegeName.Text.Trim()
                    };
                    var mailbody1 =
                        objMailTemplete.MailBodyForCollegeRegisterToAdmin(txtCollegeContactPersonName.Text.Trim(),
                                                                          txtCollegeName.Text.Trim(),
                                                                          ddlState.SelectedItem.Text,
                                                                          ddlCity.SelectedItem.Text,
                                                                          txtCollegePhone.Text.Trim(),
                                                                          txtEmailId.Text.Trim());
                    objMail1.Body = mailbody1;
                    objMail1.To.Add(ClsSingelton.CollegeRegisterationMailId);
                    objMail1.IsBodyHtml = true;
                    Utils.SendMailMessageAsync(objMail1);
                    SetStatus("CommentSuccess", errMsg);
                    ClearForm();
                    spnEmailError.Visible = false;
                }
                else
                {
                    SetStatus("CommentError", errMsg);
                }
            }
            catch (Exception ex)
            {
                var err = ex.Message;
                if (ex.InnerException != null)
                {
                    err = err + " :: Inner Exception :- " + ex.InnerException.Message;
                }
                const string addInfo =
                    "Error while executing InsertUserIdAndCollegeId in CollegeRegisteration.aspx  :: -> ";
                var objPub = new ClsExceptionPublisher();
                objPub.Publish(err, addInfo);
            }
        }