Click here to Skip to main content
15,905,587 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how can i send autogenerate mail from my asp.net application...
i want asp.net code
Posted

1 solution

Something like this: :-D

string strFrom = "me@me.com";
string strTo = "to@to.com";
string strSubject = "subject";
string strBody = "hello there";
string mailHost = "mail server name";

                using (System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage())
                {
                    msg.From = new System.Net.Mail.MailAddress(strFrom);
                    msg.To.Add(strTo);
                    
                    msg.Subject = strSubject;

                    msg.Body = strBody;

                    try
                    {
                        System.Net.Mail.SmtpClient mailClient = new System.Net.Mail.SmtpClient(mailHost);
                        mailClient.Send(msg);
                    }
                    catch (Exception caught)
                    {
                       // handle errors
                    }
                }
 
Share this answer
 
v4

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900