S
savvy
i'm trying to compile a simple console application for sending a mail,
my main idea is to schedule it to a particular time for sending mails
using the windows schedular task lateron. Therefore i need an exe file
to make that work. I compiled my file Emailtest.cs using this command
line
csc /r:System.Web.dll Emailtest.cs
and i got an .exe file but when clicking it or executing it i'm not
receiving any mail. I dont know where the problem is
Can anyone help me out please
Thanks in Advance
I'm giving my code below
using System;
using System.Web.Mail;
public class Emailtest
{
public static void Main()
{
try
{
MailMessage objMail = new MailMessage();
objMail.From = "mailfrom";
objMail.To = "(e-mail address removed)";
objMail.Subject = "test mail";
objMail.BodyFormat = MailFormat.Html;
objMail.Body = "this is for testing automatic emails.";
SmtpMail.SmtpServer = "localhost";
SmtpMail.Send(objMail);
Console.Write("Mail Sent to John Gera");
}
catch (Exception ex)
{
Console.Write(ex.Message);
}
}
}
my main idea is to schedule it to a particular time for sending mails
using the windows schedular task lateron. Therefore i need an exe file
to make that work. I compiled my file Emailtest.cs using this command
line
csc /r:System.Web.dll Emailtest.cs
and i got an .exe file but when clicking it or executing it i'm not
receiving any mail. I dont know where the problem is
Can anyone help me out please
Thanks in Advance
I'm giving my code below
using System;
using System.Web.Mail;
public class Emailtest
{
public static void Main()
{
try
{
MailMessage objMail = new MailMessage();
objMail.From = "mailfrom";
objMail.To = "(e-mail address removed)";
objMail.Subject = "test mail";
objMail.BodyFormat = MailFormat.Html;
objMail.Body = "this is for testing automatic emails.";
SmtpMail.SmtpServer = "localhost";
SmtpMail.Send(objMail);
Console.Write("Mail Sent to John Gera");
}
catch (Exception ex)
{
Console.Write(ex.Message);
}
}
}