|
|||||||
|
|
|
![]() |
|
|
Strumenti |
|
|
#1 |
|
Member
Iscritto dal: Aug 2005
Messaggi: 37
|
leggere impostazioni mail dal webconfig
salve, ho realizzato una form in c# che mi consente di inviare dati a un indirizzo di posta, l'smtp e il destinatario sono scritti nel codice.
volevo sapere come posso fare per andare a leggere questi parametri direttamente dal web config. Nel <mailSettings> del web config ho però un'altra configurazione che uso per altri form, quindi non vorrei usarla. Grazie!! code: void SendEmail(string status) { try { MailMessage oMsg = new MailMessage(); oMsg.BodyFormat = MailFormat.Html; oMsg.Subject = "Richiesta informazioni"; oMsg.Body = "<html><body>"; if (status == "GUEST") { oMsg.To = EmailTB.Text; oMsg.From = "[email protected]"; oMsg.Body += "<p>messaggio consegnato</p>"; } else { oMsg.Headers.Add("Reply-To", EmailTB.Text); oMsg.To = "[email protected]"; oMsg.From = "[email protected]"; oMsg.Body += "Hai ricevuto una richiesta informazioni."; oMsg.Body += "Richiedente:</p><p>"; oMsg.Body += "Indirizzo: " + Server.HtmlEncode(indirizzo.Text); oMsg.Body += "<br>CAP: " + Server.HtmlEncode(cap.Text); oMsg.Body += "<br>Città: " + Server.HtmlEncode(citta.Text); } oMsg.Body += "</body></html>"; SmtpMail.SmtpServer = "smtp.server.it"; SmtpMail.Send(oMsg); oMsg = null; } catch (Exception e) { Console.WriteLine("{0} Exception caught.", e); } } |
|
|
|
|
#2 |
|
Senior Member
Iscritto dal: Apr 2000
Città: Vicino a Montecatini(Pistoia) Moto:Kawasaki Ninja ZX-9R Scudetti: 29
Messaggi: 53971
|
|
|
|
|
| Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 11:53.


















