【问题标题】:IIS 7.5 SMTP Email from WCF Service来自 WCF 服务的 IIS 7.5 SMTP 电子邮件
【发布时间】:2013-07-25 21:43:01
【问题描述】:

当对 WCF 服务进行 POST 时,我正在尝试使用 IIS 中的 SMTP 电子邮件设置发送邮件。

在我的服务中,我创建了一个 MailMessage,如下所示:

        MailMessage mail = new MailMessage();

        // Set the to and from addresses.
        // The from address must be your GMail account
        mail.To.Add(new MailAddress(GetWebConfigValue("emailTo")));
        mail.From = new MailAddress("mailer@me.com");

        // Define the message
        mail.Subject = subject;
        mail.IsBodyHtml = false;
        mail.Body = body;

        // Create a new Smpt Client using Google's servers
        var mailclient = new SmtpClient();
        mailclient.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis;
        mailclient.Send(mail);

但是,当它到达DeliveryMethod 区域时,它总是会中断:SmtpExecption occurred: Cannot get IIS pickup directory.

我能够通过在 C# 中手动定义条目来使其工作,但我的代码需要针对多个部署进行更多配置。

我认为这种方法可能是一种更无缝的方式来使用 IIS 和我需要的这个功能。有人有什么想法/建议吗?

【问题讨论】:

标签: .net wcf iis smtp email


【解决方案1】:
猜你喜欢
  • 2011-02-07
  • 1970-01-01
  • 2016-01-05
  • 2013-02-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-04-07
  • 1970-01-01
相关资源
最近更新 更多