Click here to Skip to main content
16,011,947 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi

I want to send Email I want to know how to get the Smtp of my system and how to send mail with the body as follows

Name from To Number of Days Status

Thanks
Abinav Shankar
Posted

MailMessage oMsg = new MailMessage();
                oMsg.From = new MailAddress("xxx@gmail.com", "xxx");
                oMsg.To.Add(new MailAddress("yyy@gmail.com", "xxx"));
                oMsg.Subject = "Packet Parsing Problem";
                oMsg.Body = " Problem Occuread test mail";
                oMsg.SubjectEncoding = System.Text.Encoding.UTF8;
                oMsg.BodyEncoding = System.Text.Encoding.UTF8;
                oMsg.IsBodyHtml = false;
                oMsg.Priority = MailPriority.High;
 
                SmtpClient oSmtp = new SmtpClient("smtp.gmail.com", 587);
                oSmtp.DeliveryMethod = SmtpDeliveryMethod.Network;
                oSmtp.EnableSsl = true;
 
                NetworkCredential oCredential = new NetworkCredential("xxx@gmail.com", "123456aA");
                oSmtp.UseDefaultCredentials = false;
                oSmtp.Credentials = oCredential;
                oSmtp.Send(oMsg);


Try this , Its will work
 
Share this answer
 
For SMTP address, you will have to look at your Email host - the address is not fixed, and varies from system to system according to the wishes of the person who set up the system.

Once you have found it, there is a generic routine here which will help: Sending an Email in C# with or without attachments: generic routine.[^]
 
Share this answer
 
Comments
fjdiewornncalwe 16-Jan-12 10:30am    
+5. As complete an answer as the question warrants.

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