Hi All,
in my application i want's to send a mail with excel attachment, i host my application on server whenever we logged on into the server the mail send properly but whatever
when we are not logged on into server then my mail process not working...
it want's to logged on to server for sending a mail .
how to send a mail without logged on to server.
My Code is below string OutputFilePath = string.Format(Path, "ExcelFile\\" + String.Format("{0:yyyyMMdd}", oDMREntity.ForTheDay) + ".xls");
FileStream oFS = new FileStream(OutputFilePath, FileMode.Open);
MailMessage mailMsg = new MailMessage();
MailAddress mailAdd;
mailAdd = new MailAddress(ConfigurationManager.AppSettings["FromMail"]);
mailMsg.From = mailAdd;
mailMsg.To.Add(ConfigurationManager.AppSettings["DMRToMail"]);
mailMsg.CC.Add(ConfigurationManager.AppSettings["DMRCcMail"]);
mailMsg.Bcc.Add(ConfigurationManager.AppSettings["DMRBccMail"]);
Attachment data = new Attachment(oFS, Path.GetFileName(OutputFilePath));
mailMsg.Attachments.Add(data);
mailMsg.Subject = "Daily Maintenance Report | " + String.Format("{0:MMMM d, yyyy}", oDMREntity.ForTheDay);
mailMsg.Body = MailContent;
mailMsg.IsBodyHtml = true;
SmtpClient mSMTPClient = new SmtpClient();
mSMTPClient.Send(mailMsg);