Mail not getting send.

  • Thread starter Thread starter trialproduct2004
  • Start date Start date
T

trialproduct2004

Hi all,

i am having application in c# for sending mails.

I want to ask few question related to sending mail.

If address of smtp server is not set, then will the mails be send to
address specified in tomail field.

Is it neccessy to set smpt server address in mail message class.

Because in example given in msdn there is nothing done as such for
setting smpt server address.


Can someone tell me as this is very importany for me.

Any help will be truely apprecaited.

thanks in advance.
 
This works for me:
try
{
string machine = Environment.MachineName;
mail=new MailMessage();
mail.From = machine + "@mydomain.com";// OR any address
mail.To=strTo;
mail.Cc=strCC;
mail.Bcc=strBCC;
mail.Subject = strSubject;
mail.Body = strBody;
SmtpMail.SmtpServer="localhose";
// OR TRY "mail.mydomain.com";if you know it
// OR 1.1.1.127
SmtpMail.Send(mail);
}
catch(System.Web.HttpException ehttp){}

Since SmtpServer property is static, you should only have to set this
one in your app and not have to repete.

Hope this helps
 
This works for me:
try
{
string machine = Environment.MachineName;
mail=new MailMessage();
mail.From = machine + "@mydomain.com";// OR any address
mail.To=strTo;
mail.Cc=strCC;
mail.Bcc=strBCC;
mail.Subject = strSubject;
mail.Body = strBody;
SmtpMail.SmtpServer="localhose";
// OR TRY "mail.mydomain.com";if you know it
// OR 1.1.1.127
SmtpMail.Send(mail);
}
catch(System.Web.HttpException ehttp){}

Since SmtpServer property is static, you should only have to set this
one in your app and not have to repete.

Hope this helps
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top