Bonjour, j'ai un formulaire qui envoie 2 emails :
1er au client, il s'agit d'un reçu :
[MailAddress to = new MailAddress(t.MailNew);]
2e c'est à nous, il s'agit d'une notification :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 MailAddress from = new MailAddress(ConfigurationManager.AppSettings["FromCourriel"]); MailAddress to = new MailAddress(t.MailNew); MailMessage message = new MailMessage(from, to); message.Subject = "OBJET : Reçu"; message.IsBodyHtml = true; message.Body = "<p>votre courriel a été envoyé, etc...</p>"; message.BodyEncoding = System.Text.Encoding.UTF8; MailAddress bcc = new MailAddress(ConfigurationManager.AppSettings["copie_bbc"]); message.Bcc.Add(bcc); SmtpClient client = new SmtpClient(); client.Host = ConfigurationManager.AppSettings["SmtpServerURL_"]; client.Credentials = new System.Net.NetworkCredential("usernameHere", "passwordHere"); Console.WriteLine("Sending an e-mail message to {0} by using the SMTP host {1}.", to.Address, message.CC.ToString(), message.Bcc.ToString()); Console.WriteLine("Sending an e-mail message to {0} and {1}.", to.DisplayName, message.Bcc.ToString()); try { client.Send(message); } catch (Exception ex) { Console.WriteLine("Exception caught in CreateBccTestMessage(): {0}", ex.ToString()); }
[MailAddress mailNotificationNousTo = new MailAddress(ConfigurationManager.AppSettings["CourrielNotificationTO"]);]
Nous ne recevons pas le courriel, mais le client reçois 2 courriels : celui du reçu et de la notification"
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 MailAddress mailNotificationNousFrom = new MailAddress(ConfigurationManager.AppSettings["FromCourriel"]); MailAddress mailNotificationNousTo = new MailAddress(ConfigurationManager.AppSettings["CourrielNotificationTO"]); MailMessage mssgNotificationNous = new MailMessage(mailNotificationNousFrom, mailNotificationNousTo); message.Subject = "OBJET : Notification"; message.IsBodyHtml = true; // pour interpreter le code html message.Body = "<p>Il y a une notification, etc</p>"; message.BodyEncoding = System.Text.Encoding.UTF8; MailAddress bccc = new MailAddress(ConfigurationManager.AppSettings["notification_bbc"]); message.Bcc.Add(bccc); SmtpClient mssgNotificationNousClient = new SmtpClient(); mssgNotificationNousClient.Host = ConfigurationManager.AppSettings["SmtpServerURL_"]; client.Credentials = new System.Net.NetworkCredential("usernameHere", "passwordHere"); Console.WriteLine("Sending an e-mail message to {0} by using the SMTP host {0}.", mailNotificationNousTo.Address); Console.WriteLine("Sending an e-mail message to {0} and {1}.", mailNotificationNousTo.DisplayName, message.Bcc.ToString()); try { mssgNotificationNousClient.Send(message); } catch (Exception ex) { Console.WriteLine("Exception caught in CreateBccTestMessage(): {0}", ex.ToString()); }
comment je peux le corriger ?
Merci
Partager