Bonjour,
Je veux savoir comment pourrai-je faire pour envoyer des alertes mail automatiquement aux personnes inscrits dans mon site avec c# sous dotnet.
Merci
Version imprimable
Bonjour,
Je veux savoir comment pourrai-je faire pour envoyer des alertes mail automatiquement aux personnes inscrits dans mon site avec c# sous dotnet.
Merci
Je me rappel qu on avais une classe héritée de SmtpClient... dans le genre :
Code:
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 public class CMailSender : SmtpClient { static String s_sSenderUser = "yy.xx"; static String s_sSenderUserAddress = s_sSenderUser + "@zz.com"; static String s_sSenderPassword = "pouetpouet"; static String s_sDestinationAddress = "qq.ww@rr.com"; public CMailSender() : base("host.server.com", 1234567890) { // Command line argument must the the SMTP host. base.EnableSsl = true; base.Credentials = new System.Net.NetworkCredential(s_sSenderUser, s_sSenderPassword); } public void Send(String _strSenderName, String _strSubject, String _strBody, IList<String> _Attachments, SendCompletedEventHandler _SendEventHandler) { // Specify the e-mail sender. // Create a mailing address that includes a UTF8 character // in the display name. MailAddress from = new MailAddress(s_sSenderUserAddress, _strSenderName, System.Text.Encoding.UTF8); // Set destinations for the e-mail message. MailAddress to = new MailAddress(s_sDestinationAddress); // Specify the message content. MailMessage message = new MailMessage(from, to); message.Subject = _strSubject; message.SubjectEncoding = System.Text.Encoding.UTF8; message.Body = _strBody; message.BodyEncoding = System.Text.Encoding.UTF8; foreach (string iAttach in _Attachments) { FileInfo fi = new FileInfo(iAttach); if (fi.Exists) { Attachment attached = new Attachment(iAttach, MediaTypeNames.Application.Octet); message.Attachments.Add(attached); } } base.SendCompleted += _SendEventHandler; base.SendAsync(message, _strSubject); } }