How to send e-mail
-
hi everyone! i'm making an application and i want to use in it an error reporting system. i want to make the program sent an email (with enclosure) without open the email browser. just send it... i want to specify the enclosure (e.g. the path of a picture). can someone help me? Thanks in advance Enrico VentoEngine corp. Program your life ^^
-
hi everyone! i'm making an application and i want to use in it an error reporting system. i want to make the program sent an email (with enclosure) without open the email browser. just send it... i want to specify the enclosure (e.g. the path of a picture). can someone help me? Thanks in advance Enrico VentoEngine corp. Program your life ^^
-
For framework 1.1: System.Web.Mail namespace. For framework 2.0: System.Net.Mail namespace. --- b { font-weight: normal; }
-
Ventomito, Here's a routine I keep around for such things. You'll naturally need to insert the name of your smtp server in the slot indicated. Hope this helps.
using System.Web.Mail; protected Boolean SendEmail(string strFromEmail, string strToEmail, string strSubject, string strBody) { Boolean bStat = false; try { MailMessage Message = new MailMessage(); Message.To = strToEmail; Message.From = strFromEmail; Message.Subject = strSubject; Message.Body = strBody; // enter your smtp server here // if login is required you may need extra params // see the doc for the SmtpMail object SmtpMail.SmtpServer = "your.smtpserver.com"; SmtpMail.Send(Message); bStat = true; } catch (Exception) { bStat = false; } return (bStat); }
Author of The Career Programmer and Unite the Tribes Know someone who desperately needs to get a clue? Visit www.DownloadAClue.com and send them one!