My send mail Code below is not working correctly. It is not sending any email or returning any errors. I'm not getting an Exception thrown at all from the below code. How would I set up to catch common errors that may be happening in the below code?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Net.Mail;
using System.Net;
namespace DataAccess
{
public class DLSendMails
{
public string SendCommentMails(String MemberEmail, int
{
try
{
using (SmtpClient client =
new SmtpClient("smtpout.secureserver.net"))
{
client.Credentials =
new NetworkCredential("webmaster@mysite.com", "pwd");
//client.Credentials
// = CredentialCache.DefaultNetworkCredentials;
//client.DeliveryMethod
// = SmtpDeliveryMethod.Network;
string to = MemberEmail;
var mail = new MailMessage();
mail.From = new MailAddress("webmaster@mysite.com",
"mysite.com");
mail.To.Add(to);
mail.Subject = "New Comment recieved at mysite.com";
mail.Body = "You can read your comment and access your "
+ "profile page by using this link.\n"
+ "http://www.mysite.com/Member.aspx?UserID="
+ PicID;
mail.IsBodyHtml = true;
client.Send(mail);
return "sent mail";
}
}
catch (Exception ex)
{
// exception handling
return ex.ToString();
}
}
}
}