MelinaMelina
-
Modifié par jordane45 le 6/06/2014 à 16:50
jordane45
Messages postés38145Date d'inscriptionmercredi 22 octobre 2003StatutModérateurDernière intervention25 avril 2024
-
6 juin 2014 à 16:50
Bonjour, SVp j'utilise ce code pour envoyer un message à une boite gmail et avoir un accusé de reception, pour l'envoie ça marche sans problème mais je n'ai pas d'accusé, veuillez bien m'aidez svp :
using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Net.Mail;
public partial class _Default : System.Web.UI.Page
{
protected void Button1_Click(object sender, EventArgs e)
{
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com";
smtp.Port = 587;
smtp.Credentials = new System.Net.NetworkCredential("***@***", "password");
smtp.EnableSsl = true;
MailMessage msg = new MailMessage();
msg.Subject = "Demo";
msg.Body = "Hi there..SVP cliquer sur ce lien www.google.com";
string toAddress = "***@***"; // Add Recepient address
msg.DeliveryNotificationOptions = DeliveryNotificationOptions.OnSuccess;
//msg.Headers.Add("Read-Receipt-To", "***@***");
msg.Headers.Add("Disposition-Notification-To", "***@***");
msg.To.Add(toAddress);
// Set delivery notifications for success and failed messages
string fromAddress = "\"no reply \" <***@***>"; // From Email Address
msg.From = new MailAddress(fromAddress);
msg.IsBodyHtml = true;
try
{
smtp.Send(msg);
}
catch
{
throw;
}
}
}