Reporting Services 2005 用の独自の配信拡張機能を開発し、これを SaaS マーケティング ソリューションと統合しました。
サブスクリプションを取得し、カスタム パラメーター セットを使用してレポートのスナップショットを取得します。次に、レポートをレンダリングし、リンクとレポートを XLS として添付した電子メールを送信します。
メール配信まで、すべて正常に動作します...
電子メールを送信するための私のコードは次のとおりです。
public static List<string> SendMail(SubscriptionData data, Stream reportStream, string reportName, string smptServerHostname, int smtpServerPort)
{
List<string> failedRecipients = new List<string>();
MailMessage emailMessage = new MailMessage(data.ReplyTo, data.To);
emailMessage.Priority = data.Priority;
emailMessage.Subject = data.Subject;
emailMessage.IsBodyHtml = false;
emailMessage.Body = data.Comment;
if (reportStream != null)
{
Attachment reportAttachment = new Attachment(reportStream, reportName);
emailMessage.Attachments.Add(reportAttachment);
reportStream.Dispose();
}
try
{
SmtpClient smtp = new SmtpClient(smptServerHostname, smtpServerPort);
// Send the MailMessage
smtp.Send(emailMessage);
}
catch (SmtpFailedRecipientsException ex)
{
// Delivery failed for the recipient. Add the e-mail address to the failedRecipients List
failedRecipients.Add(ex.FailedRecipient);
}
catch (SmtpFailedRecipientException ex)
{
// Delivery failed for the recipient. Add the e-mail address to the failedRecipients List
failedRecipients.Add(ex.FailedRecipient);
}
catch (SmtpException ex)
{
throw ex;
}
catch (Exception ex)
{
throw ex;
}
// Return the List of failed recipient e-mail addresses, so the client can maintain its list.
return failedRecipients;
}
SmtpServerHostname の値は localhost、ポートは 25 です。
Telnet を使用して、実際にメールを送信できることを確認しました。そして、それは機能します。
SSRSから取得したエラーメッセージは次のとおりです。
ReportingServicesService!notification!4!08/28/2008-11:26:17:: 通知 6ab32b8d-296e-47a2-8d96-09e81222985c が完了しました。成功: False、ステータス: 例外メッセージ: メールの送信に失敗しました。スタックトレース: C:\inetpub\wwwroot\CustomReporting\MyDeliveryExtension\MailDelivery.cs: 48 行目の MyDeliveryExtension.MyDelivery.Deliver(Notification C:\inetpub\wwwroot\CustomReporting\MyDeliveryExtension\MyDelivery.cs:153 行目、DeliveryExtension: My Delivery、Report: Clicks Development、試行 1 ReportingServicesService!dbpolling!4!08/28/2008-11:26:17 :: NotificationPolling は項目 6ab32b8d-296e-47a2-8d96-09e81222985c の処理を終了しました
これは Trust/Code Access Security と関係がありますか?
私の配信拡張機能には、rssrvpolicy.config で完全な信頼が付与されています。
<CodeGroup
class="UnionCodeGroup"
version="1"
PermissionSetName="FullTrust"
Name="MyDelivery_CodeGroup"
Description="Code group for MyDelivery extension">
<IMembershipCondition class="UrlMembershipCondition" version="1" Url="C:\Program Files\Microsoft SQL Server\MSSQL.2\Reporting Services\ReportServer\bin\MyDeliveryExtension.dll" />
</CodeGroup>
ここで信頼が問題になる可能性はありますか?
別の理論: SQL Server と SSRS は、ローカル システムのセキュリティ コンテキストにインストールされました。そうですか、このサービス アカウントはネットワーク リソースへのアクセスが制限されていますか? 独自の SMTP サーバーでさえ?
すべての SQL Server サービス ログオンを管理者に変更しようとしましたが、それでも成功しませんでした。
また、NetworkCredential("Administrator", "password") および NetworkCredential("Administrator", "password", "MyRepServer") を指定して、コードで SMTP サーバーにログオンしようとしました。
誰でもここで助けてもらえますか?