我开发了一个生成报告的应用程序,生成的报告应该通过电子邮件发送到配置文件中给出的地址。 Andmy代码只向outlook发送电子邮件,而我在实时环境中不会有任何我希望发送它的Outlook。 我怎么能做到这一点?
public void DCCEmailSetup(DateTime dateRunReport, string path, string messager)
{
toEmailSetup = ConfigurationManager.AppSettings["To mailid"];
fromEmailSetup = ConfigurationManager.AppSettings["From mailid"];
try
{
var message = new MailMessage();
message.To.Add(toEmailSetup);
message.Subject = " Report generated " + dateRunReport;
message.From = new MailAddress(fromEmailSetup);
try
{
message.Attachments.Add(new Attachment(path));
message.Body = messager;
}
catch (Exception e)
{
throw ;
}
var smtp = new SmtpClient(" ");
smtp.Send(message);
}
catch (SmtpException ex)
{
throw new ApplicationException
("SmtpException has occured: " + ex.Message);
}
}
答案 0 :(得分:1)
如果您的实时环境无法访问Exchange服务器,则需要访问中继或能够将邮件转发到Exchange /电子邮件服务器的内容,否则无法发送电子邮件。对不起:(