email registrazione e etichette
This commit is contained in:
parent
d63666b950
commit
3d5a6b0cc3
@ -1,6 +1,9 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
using NuGet.Protocol.Plugins;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using System.Net.Mail;
|
||||||
|
using System.Net;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using VirtualTask.Models;
|
using VirtualTask.Models;
|
||||||
@ -116,7 +119,6 @@ namespace VirtualTask.Controllers
|
|||||||
{
|
{
|
||||||
|
|
||||||
urlBase = apiUrl + "registrazioni/add";
|
urlBase = apiUrl + "registrazioni/add";
|
||||||
//urlBase = "http://10.0.0.187:8000/api/Polo/registrazioni/add";
|
|
||||||
Uri baseAddress = new Uri(urlBase);
|
Uri baseAddress = new Uri(urlBase);
|
||||||
client = new HttpClient();
|
client = new HttpClient();
|
||||||
client.BaseAddress = baseAddress;
|
client.BaseAddress = baseAddress;
|
||||||
@ -127,6 +129,8 @@ namespace VirtualTask.Controllers
|
|||||||
|
|
||||||
if (response.IsSuccessStatusCode)
|
if (response.IsSuccessStatusCode)
|
||||||
{
|
{
|
||||||
|
//mando mail avvenuta richiesta
|
||||||
|
bool esito = MailSent(model.email);
|
||||||
return RedirectToAction("RegistrazioneOk");
|
return RedirectToAction("RegistrazioneOk");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -386,6 +390,52 @@ namespace VirtualTask.Controllers
|
|||||||
}
|
}
|
||||||
return bAziPres;
|
return bAziPres;
|
||||||
}
|
}
|
||||||
|
private bool MailSent(string receiver)
|
||||||
|
{
|
||||||
|
//REMEMBER per una mail gmail bisogna andare nelle impostazioni
|
||||||
|
//e impostare "Accesso app meno sicure" a ON
|
||||||
|
bool sent = false;
|
||||||
|
|
||||||
|
string senderMail = _configuration["ApplicationInsights:mittenteMail"];
|
||||||
|
string senderName = _configuration["ApplicationInsights:nomeMail"];
|
||||||
|
string pwdMail = _configuration["ApplicationInsights:pwdMail"];
|
||||||
|
|
||||||
|
|
||||||
|
string subject = _configuration["ApplicationInsights:subjectMail"];
|
||||||
|
string message = getMailText();
|
||||||
|
|
||||||
|
var senderEmail = new MailAddress(senderMail, senderName);
|
||||||
|
var receiverEmail = new MailAddress(receiver, "Receiver");
|
||||||
|
var password = pwdMail;
|
||||||
|
var sub = subject;
|
||||||
|
var body = message;
|
||||||
|
var smtp = new SmtpClient
|
||||||
|
{
|
||||||
|
Host = "smtp.gmail.com",
|
||||||
|
Port = 587,
|
||||||
|
EnableSsl = true,
|
||||||
|
|
||||||
|
DeliveryMethod = SmtpDeliveryMethod.Network,
|
||||||
|
UseDefaultCredentials = false,
|
||||||
|
Credentials = new NetworkCredential(senderEmail.Address, password)
|
||||||
|
};
|
||||||
|
using (var mess = new MailMessage(senderEmail, receiverEmail)
|
||||||
|
{
|
||||||
|
Subject = subject,
|
||||||
|
Body = body
|
||||||
|
})
|
||||||
|
{
|
||||||
|
smtp.Send(mess);
|
||||||
|
}
|
||||||
|
return sent;
|
||||||
|
}
|
||||||
|
|
||||||
|
private string getMailText()
|
||||||
|
{
|
||||||
|
string txt = string.Empty;
|
||||||
|
txt = "contenuto mail di registrazione";
|
||||||
|
return txt;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,23 +19,27 @@
|
|||||||
@Html.HiddenFor(x => x.latipcli)
|
@Html.HiddenFor(x => x.latipcli)
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
<h5><label asp-for="lacodcom" class="agy-client-quote"></label></h5>
|
||||||
<input asp-for="lacodcom" class="agy-form-field require" placeholder="Cod. commessa" />
|
<input asp-for="lacodcom" class="agy-form-field require" placeholder="Cod. commessa" />
|
||||||
<span asp-validation-for="lacodcom" class="text-danger"></span>
|
<span asp-validation-for="lacodcom" class="text-danger"></span>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-lg-6 col-md-6 col-sm-12 col-12"> </div>
|
<div class="col-lg-6 col-md-6 col-sm-12 col-12"> </div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
<h5><label asp-for="ladeslav" class="agy-client-quote"></label></h5>
|
||||||
<input asp-for="ladeslav" class="agy-form-field require" placeholder="Fase Commessa" />
|
<input asp-for="ladeslav" class="agy-form-field require" placeholder="Fase Commessa" />
|
||||||
<span asp-validation-for="ladeslav" class="text-danger"></span>
|
<span asp-validation-for="ladeslav" class="text-danger"></span>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-lg-6 col-md-6 col-sm-12 col-12"> </div>
|
<div class="col-lg-6 col-md-6 col-sm-12 col-12"> </div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
@* @Html.DropDownListFor(x => x.lacodcli,(IEnumerable<SelectListItem>)ViewBag.Anag, new{@class = "form-control"})*@
|
@* @Html.DropDownListFor(x => x.lacodcli,(IEnumerable<SelectListItem>)ViewBag.Anag, new{@class = "form-control"})*@
|
||||||
|
<h5><label asp-for="lacodcli" class="agy-client-quote"></label></h5>
|
||||||
@Html.DropDownListFor(x => x.lacodcli, (IEnumerable<SelectListItem>)ViewBag.Anag, "--Seleziona un cliente--", new { @id="ddlClienti",@class = "form-control"})
|
@Html.DropDownListFor(x => x.lacodcli, (IEnumerable<SelectListItem>)ViewBag.Anag, "--Seleziona un cliente--", new { @id="ddlClienti",@class = "form-control"})
|
||||||
<span asp-validation-for="lacodcli" class="text-danger"></span>
|
<span asp-validation-for="lacodcli" class="text-danger"></span>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-lg-6 col-md-6 col-sm-12 col-12"> </div>
|
<div class="col-lg-6 col-md-6 col-sm-12 col-12"> </div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
@* @Html.DropDownListFor(x => x.lacodimp,(IEnumerable<SelectListItem>)ViewBag.Impianti, new{@class = "form-control"})*@
|
@* @Html.DropDownListFor(x => x.lacodimp,(IEnumerable<SelectListItem>)ViewBag.Impianti, new{@class = "form-control"})*@
|
||||||
|
<h5><label asp-for="lacodimp" class="agy-client-quote"></label></h5>
|
||||||
<div id="District">
|
<div id="District">
|
||||||
@Html.DropDownListFor(x => x.lacodimp, new List<SelectListItem>(), "--Seleziona un impianto--", new { @id="ddlImpianti",@class = "form-control"})
|
@Html.DropDownListFor(x => x.lacodimp, new List<SelectListItem>(), "--Seleziona un impianto--", new { @id="ddlImpianti",@class = "form-control"})
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -6,7 +6,11 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"ApplicationInsights": {
|
"ApplicationInsights": {
|
||||||
"rootUrlApi": "https://api.poloinformatico.it:9000/api/Polo/"
|
"rootUrlApi": "https://api.poloinformatico.it:9000/api/Polo/",
|
||||||
|
"mittenteMail": "audiffredi@poloinformatico.it",
|
||||||
|
"nomeMail": "Supporto Virtual Task",
|
||||||
|
"pwdMail": "audicruz70",
|
||||||
|
"subjectMail": "Richiesta App di test"
|
||||||
},
|
},
|
||||||
"AllowedHosts": "*"
|
"AllowedHosts": "*"
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user