I wrote the follownig program
Expand|Select|Wrap|Line Numbers
- using System;
- using System.Web.Mail;
- public class MailHelper
- {
- public static void SendMail(string mailId, string author, string email,
- string title, string msgDate, string comment)
- {
- String msg = String.Format("{0} (email: {1}) has just posted a comment
- on the message \"{2}\" of your BLOG that you posted at {3}. Here's the
- comment: {4}{4}{5}",
- author,
- email,
- title,
- msgDate,
- Environment.NewLine,
- comment
- );
- try
- {
- //SmtpMail.SmtpServer = "localhost";
- MailMessage mail = new MailMessage();
- mail.To = mailId;
- mail.From = "ab******@hotmail.com";
- mail.Subject = "New BLOG comment notification";
- mail.Body = msg;
- SmtpMail.Send(mail);
- }
- catch(Exception ex)
- {
- Console.WriteLine(ex);
- Console.WriteLine("*****************");
- Console.WriteLine(ex.InnerException.Message);
- Console.WriteLine("*****************");
- Console.WriteLine(ex.InnerException.InnerException.Message);
- throw ex;
- }
- }
- }
well.
I have configured the SMTP service on my local machine itself. I have
also gone into SMTP server properties and into the "Access->Relay"
option and added my machine IP (127.0.0.1 and my ip address) into the
list of "only the list below" option.
Please do help me... why am I not able to send the email?
regards,
Abhishek.