1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151
|
private bool SendMail_MouvementProduit()
{
try
{
MailMessage message = new MailMessage();
SmtpClient smtp = new SmtpClient();
//HtmlTable tbl = new HtmlTable;
_lisprod = "<table ><font-size=3;><style = 'border-collapse: collapse';>" +
"<tr>" +
"<th align='center'>" + "PRODUIT" + "</th>" +
"<th align='center'>" + "Initial" + "</th>" +
"<th align='center'>" + "Entrée" + "</th>" +
"<th align='center'>" + "Sortie" + "</th>" +
"<th align='center'>" + "Vente à Crédit" + "</th>" +
"<th align='center'>" + "Vente Au Comptant" + "</th>" +
"<th align='center'>" + "Stock Final" + "</th>" +
"</tr>";
_listMouvement = ARTICLE.Get_EMAILLING_MOUVEMENT_PRODUIT(transReception,Id_depot, Parm_Base.id_Societe, Parm_Base.DateOuverte.Date, Parm_Base.DateOuverte.Date,
crichefAgence, cridepot, Parm_Base.St_VersionLogiciel, Parm_Base.St_NamePoster);
//decimal MttGlob = _ListFSTOCK_MARQUE[0].ValeurGlobal;
compt = 0;
for (compt = 0; compt < _listMouvement.Count; compt++)
{
_lisprod = _lisprod +
// "<th>" + "Initial" + "</th>" +
// "<th>" + "Entrée" + "</th>" +
// "<th>" + "Sortie" + "</th>" +
// "<th>" + "Vente à Crédit" + "</th>" +
// "<th>" + "Vente Au Comptant" + "</th>" +
// "<th>" + "Stock Final" + "</th>" +
// "</tr>" +
"<tr>" +
"<td border: 1px solid black;>" + _listMouvement[compt].LBLPRODUIT + "</td>" +
//"<td border: 1px solid black;>" + _listMouvement[compt]. + "</td>" +
"<td border: 1px solid black;>" + string.Format("{0:### ### ##0.}", _listMouvement[compt].Initial) + "</td>" +
"<td border: 1px solid black;>" + string.Format("{0:### ### ##0.}", _listMouvement[compt].Entrees) + "</td>" +
"<td border: 1px solid black;>" + string.Format("{0:### ### ##0.}", _listMouvement[compt].Sorties) + "</td>" +
"<td border: 1px solid black;>" + string.Format("{0:### ### ##0.}", _listMouvement[compt].VenteACredit) + "</td>" +
"<td border: 1px solid black;>" + string.Format("{0:### ### ##0.}", _listMouvement[compt].VenteAuComptant) + "</td>" +
"<td border: 1px solid black;>" + string.Format("{0:### ### ##0.}", _listMouvement[compt].StockFInal) + "</td>" +
"</tr>";
}
_lisprod = _lisprod + "</table>";
message.From = new MailAddress("ed1c@outlook.fr");
message.To.Add(new MailAddress("ddd@gmail.com"));
message.CC.Add(new MailAddress("min@yahoo.fr"));
//message.To.Add(new MailAddress("@yahoo.fr"));
message.Subject = "Cahier de situation Journalière : Mouvement Produit - Agence : " + cridepot + " - " + Parm_Base.NameSociete;
message.IsBodyHtml = true;
message.Body = "Bonjour, " + "\n" +
"Recevez notre situation journalière du " + Parm_Base.DateOuverte.ToString("dd/MM/yyyy") + " à " + DateTime.Now.ToString("hh:mm") +
". Ci-dessous la liste : " +
"\n" + _lisprod + "\n" +
"\n" + "Merci de faire confiance à " + Parm_Base.St_VersionLogiciel + "\n";
smtp.Port = 587;
smtp.Host = "smtp.live.com";
smtp.EnableSsl = true;
smtp.UseDefaultCredentials = false;
smtp.Credentials = new NetworkCredential("ed1c@outlook.fr", "#data#");
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
smtp.Send(message);
}
catch (SqlException ex)
{
//transReception.Rollback("processStart");
title = Param.SoftName;
string message = string.Format("Une erreur est survenue. Raison: {0}", ex);
MessageBox.Show(message, title, MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
catch (ArithmeticException ex)
{
//transReception.Rollback("processStart");
title = Param.SoftName;
string message = string.Format("Une erreur arithmétique est survenue. Raison: {0}", ex);
MessageBox.Show(message, title, MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
catch (ArgumentOutOfRangeException ex)
{
//transReception.Rollback("processStart");
title = Param.SoftName;
string message = string.Format("L'index est en dehors de la zone. Raison: {0}", ex.ParamName);
MessageBox.Show(message, title, MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
catch (IOException ex)
{
//transReception.Rollback("processStart"); //Console.WriteLine("Une erreur d'entrée/sortie s'est produite : {0}", ex.Message);
//transReception.Rollback();
title = Param.SoftName;
string message = string.Format("Une erreur d'entrée/sortie s'est produite : {0}", ex);
MessageBox.Show(message, title, MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
catch (UnauthorizedAccessException ex)
{
//transReception.Rollback("processStart");
title = Param.SoftName;
string message = string.Format("L'accès a été refusé : {0}", ex);
MessageBox.Show(message, title, MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
catch (ArgumentNullException ex)
{
//transReception.Rollback("processStart");
title = Param.SoftName;
string message = string.Format("La valeur null a été levée : {0}", ex);
MessageBox.Show(message, title, MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
catch (NullReferenceException ex)
{
//transReception.Rollback("processStart");
//transReception.Rollback();
title = Param.SoftName;
string message = string.Format("La valeur null a été levée : {0}", ex);
MessageBox.Show(message, title, MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
catch (Exception ex)
{
//transReception.Rollback("processStart");
title = Param.SoftName;
string message = string.Format("Une erreur est survenue. Raison: {0}", ex);
MessageBox.Show(message, title, MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
return true;
} |
Partager