protected void btnEmailKS_Click(object sender, EventArgs e) { using (PoslovniKlubBL temp = new PoslovniKlubBL()) { string grad = temp.GetGradByID(ddlOpstina.SelectedIndex+1); int filijala = temp.getFilijalaByKS(Request.QueryString["emailKS"]); string bm = temp.getBM(filijala); //if (filijala == "1300") // bm = "*****@*****.**"; //else if (filijala == "1500") // bm = "*****@*****.**"; //else if (filijala == "1800") // bm = "*****@*****.**"; //else // ClientScript.RegisterStartupScript(this.GetType(), "Greška!", "alert('Nešto nije u redu!');", true); string poruka = "Poštovani/Poštovana,<br/><br/>" + "Na sporazumu " + txtSporazum.Text + " su upisani sledeći podaci:<br/>" + "JMBG: " + txtJMBG.Text + ";<br/>Adresa: " + txtAdresa.Text + ";<br/>Opština: " + grad + ";<br/>Telefon: " + txtTelefon.Text + ";<br/>Telefon2: " + txtTelefon2.Text + ";<br/>Mobitel: " + txtMobitel.Text + "<br/><br/>Molim Vas da izvršite izmjenu u registru lica."; //MessageBox.Show(poruka); MailMessage msg = new MailMessage(); System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient(); try { msg.Subject = "Izmijenjeni podaci klijenta " + txtPrezime.Text + " " + txtIme.Text; msg.Body = poruka; // "Add Email Body Part"; msg.From = new MailAddress("*****@*****.**"); msg.To.Add(Request.QueryString["EmailKS"]); msg.CC.Add(bm); msg.IsBodyHtml = true; client.Host = "smtp-relay.gmail.com"; //System.Net.NetworkCredential basicauthenticationinfo = new System.Net.NetworkCredential("*****@*****.**",""); client.Port = int.Parse("587"); client.EnableSsl = true; client.UseDefaultCredentials = false; //client.Credentials = basicauthenticationinfo; client.DeliveryMethod = SmtpDeliveryMethod.Network; client.Send(msg); } catch (Exception ex) { ClientScript.RegisterStartupScript(this.GetType(), "Greška!", "alert('Email nije otišao KS!' + ex.ToString());", true); //System.Windows.Forms.MessageBox.Show("Exception caught in CreateCopyMessage(): " + ex.ToString()); } } }