Click to See Complete Forum and Search --> : to send mail through SMTP


tika
04-25-2007, 06:33 AM
hi,

can anyone temme how to send mail through SMTP that does not depend on any mail client??

i mean the code for doin the ablove.
it wud be very helpful if some one can help me regarding this issue.

regards,
tika.

tika
04-25-2007, 06:37 AM
hope u all can understand my requirement.
i had used MAPI to send mail but the problem is outlook has to be configured. my issue is if there is no client installed on the server how do i send mail so i need to write a code that sends amil without depending on any mail client?
hope am clear enough.
hoping some one to help me regarding this as soon as possible.
thanks in advance!!

pontonet
04-25-2007, 08:50 AM
Sorry, i didn`t understand exactly your problem.
Do you have a smtp server? So you can try the following:

private void SendMail(string emailFrom, string emailTo, string subject, string body, string smtpServer)
{
try
{
MailAddress m1 = new MailAddress(emailFrom);
MailAddress m2 = new MailAddress(emailTo);

MailMessage message = new MailMessage(m1, m2);
message.Body = body;
message.Subject = subject;
message.IsBodyHtml = true;

SmtpClient smptClient = new SmtpClient(smtpServer);
smptClient.Send(message);

}
catch(Exception ex)
{
throw (new ApplicationException("Não foi possível enviar o e-mail.", ex));
}
}

Hope it helps you!

See you

tika
04-26-2007, 12:41 AM
hi,

thanks for the reply..

i should give the smtp server name alone with the userid an password. i mean i should specify the userid ,password,smtpservername or domain name,subject,body in an ini file so that the user can chnage the requirements as per their needs.i have an enterprise server.i should montior the services an send a mail wen the serveice fails thats my main requirement.

it should be scheduled on enterprise server so that it automatically sends a mail wen the service fails.

i dono how to compile the code in .net can u pls help.
thanks.

tika
04-26-2007, 12:42 AM
wen am sending a mial i should be able to send it to 5 ppl at a time i mean in case am sending a mial to a grp which had ten ppl .......

i should also validate the userid by giving a password.

if am clr enough pls lemme no.
thanks,.