Hi,
I am using following code to send email:
MailMessage Mailer = new MailMessage();
Mailer.From = new MailAddress(From);
Mailer.To.Add(new MailAddress(To));
Mailer.Subject = Subject;
Mailer.Body = Body;
Mailer.IsBodyHtml = isBodyHTML;
SmtpClient mSmtpClient = new SmtpClient();
mSmtpClient.Host = "ExchangeServer.XXX.YYY.COM"; // Our Exchange server Name
Mailer.Attachments.Add(new System.Net.Mail.Attachment(strLogFile));
mSmtpClient.Send(Mailer);
I stopped my SMTP service but still mail was sent sucessfully. I just want to understand if my SMTP service is stopped how could program send email, shouldn't it be dumped in the mailroot folder?
Thanks, Praveen
From stackoverflow
-
Looks like you've told it to use the exchange server with this line here:
mSmtpClient.Host = "ExchangeServer.XXX.YYY.COM"; // Our Exchange server NameSo it won't use your smtp service at all. Change that line of code to this:
mSmtpClient.Host = "localhost";It will start using the local smtp service, and will fail if you try to run the code with the service stopped.
: Thats what I was also thinking. Thanks for clearing my doubt.
0 comments:
Post a Comment