Sending mail
-
include //--------------------------------------------------------------------------- using System.Web.Mail; public static string SendMail(int pintUserID, string pstrMailTo, string pstrMailBcc,string pstrMailCc,string pstrMailSubject,string pstrMailBody,string pstrAttachFilePath) { try { MailMessage objMail = new MailMessage(); objMail.From = System.Configuration.ConfigurationSettings.AppSettings["FromEmailID"]; //objMail.From =System.Web.HttpContext.Current.Session["OfficeEmailID"].ToString() ; objMail.To = pstrMailTo; objMail.Bcc = pstrMailBcc; objMail.Cc = pstrMailCc; objMail.Subject = pstrMailSubject; MailAttachment Attachment = null;if (File.Exists(pstrAttachFilePath)) { Attachment = new MailAttachment(pstrAttachFilePath); } objMail.Attachments.Add(Attachment); SmtpMail.SmtpServer = "localhost";//System.Configuration.ConfigurationSettings.AppSettings["SMTPServerIP"]; SmtpMail.Send(objMail);return "TRUE"; } catch(Exception Ex) { return Ex.Message; } } Config file call the function SendMail & enable your system SMTP server.
Thanks & Regards
-
http://systemnetmail.com/[^] has many examples.
All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia How to use google | Ask smart questions
-
include //--------------------------------------------------------------------------- using System.Web.Mail; public static string SendMail(int pintUserID, string pstrMailTo, string pstrMailBcc,string pstrMailCc,string pstrMailSubject,string pstrMailBody,string pstrAttachFilePath) { try { MailMessage objMail = new MailMessage(); objMail.From = System.Configuration.ConfigurationSettings.AppSettings["FromEmailID"]; //objMail.From =System.Web.HttpContext.Current.Session["OfficeEmailID"].ToString() ; objMail.To = pstrMailTo; objMail.Bcc = pstrMailBcc; objMail.Cc = pstrMailCc; objMail.Subject = pstrMailSubject; MailAttachment Attachment = null;if (File.Exists(pstrAttachFilePath)) { Attachment = new MailAttachment(pstrAttachFilePath); } objMail.Attachments.Add(Attachment); SmtpMail.SmtpServer = "localhost";//System.Configuration.ConfigurationSettings.AppSettings["SMTPServerIP"]; SmtpMail.Send(objMail);return "TRUE"; } catch(Exception Ex) { return Ex.Message; } } Config file call the function SendMail & enable your system SMTP server.
Thanks & Regards
If you provide answers to fools to lazy to use Google you will only encourage them.
Simon