Click here to Skip to main content
15,888,803 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
Hi everyone

I want to send an email and get a delivery receipt. I have come across the DeliveryNotificationOptions property. Now it all works fine without me using network credentials.

Will this have any effect on the receiver mail server sending the delivery receipts back?

Are the network credentials with the smtpclient only used on some smtp servers, which check for username,password before allowing the sending of emails?


MailMessage msg = new MailMessage();

msg.From = new MailAddress("xxxx@xxxx.com","xxxxxxxxxx");

msg.To.Add("xxx@xxx.com"); // Who's it to
msg.Subject = "Subject line";
msg.Body = "<html><h1>Big header</h1><p>And some smaller text</p></html>";
msg.IsBodyHtml = true;
        
// Delivery notifications
msg.DeliveryNotificationOptions =
DeliveryNotificationOptions.OnFailure |
DeliveryNotificationOptions.OnSuccess |
DeliveryNotificationOptions.Delay;


SmtpClient smtp = new SmtpClient("xxxxxxxxx");
// Using authentication to connect to above smtp server to send email.
// Replace txtSMTPUser and txtSMTPPass with your appropriate details.
/*System.Net.NetworkCredential SMTPUserInfo = new System.Net.NetworkCredential("xxxx@xxxxx", "xxxxxxx");
smtp.UseDefaultCredentials = false;
smtp.Credentials = SMTPUserInfo;*/

smtp.Send(msg);
Posted

User credentials for SMTP server serves no purpose more than to authenticate while sending an email. It ensures that noone with proper credentials could send an email via the server.

And, this has no relation to the delivery receipt.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 8-Jan-13 21:22pm    
Captain Obvious at work! :-) My 5.
—SA
You need it if the server requires it to log in.
 
Share this answer
 
Comments
Member 9344823 8-Jan-13 16:26pm    
Will this have any effect on the receiver mail server sending the delivery receipts back?
Christian Graus 8-Jan-13 16:27pm    
No, it simply defines if you can send mail at all. If the mail server requires it, they would not send without it.
Sergey Alexandrovich Kryukov 8-Jan-13 21:23pm    
Captain Obvious won't let you down. :-) My 5.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900