Rules & Alerts - Developing an Alerts Web Service that Uses Outlook 2003 Alerts

A

Andrew Denler

Referring to document
http://msdn.microsoft.com/library/d...odc_ol2003_ta/html/odc_olalertswebservice.asp, I
have tried to set up the sample code for a web service for an outlook alert.

I have had little success so far. The web service compiles correctly, but
the code to send the alert email using CDO (see below) fails on "Send":

MailMessage Message = new MailMessage();
Message.To = emailAddr;
Message.From =
ConfigurationSettings.AppSettings["senderEmailAddr"];
Message.Subject = "You have successfully created an alert for "
+ URL + ".";
Message.Headers.Add("X-AlertWebUrl",
ConfigurationSettings.AppSettings["alertweburl"]);
Message.Headers.Add("X-AlertTitle",AlertTitle);
string msgId = "<" + msgPrefix + (msgIdCounter++).ToString() +
"@microsoft.com>";
Message.Headers.Add("message-id",msgId);

Message.Headers.Add("X-AlertId","{D32A01E6-8A46-41BF-8E0E-936F254ACA4A}");
Message.Headers.Add("X-AlertServerType","Third Party");

Message.Headers.Add("X-AlertWebSoap",ConfigurationSettings.AppSettings["webs
erviceurl"]);

Message.Body = "Hello, " + username + ".\n\n" + msgBody + URL +
".\n\n- RSS Sample
Web Service";
try
{
SmtpMail.SmtpServer =
ConfigurationSettings.AppSettings["smtpserver"];
SmtpMail.Send(Message);
}
catch(System.Web.HttpException ehttp)
{
return AddAlertErrorType.HttpException;
}


The error I get is "System.Runtime.InteropServices.COMException: Fields
update failed. For further information, examine the Status property of
individual field objects." It is specifically as a result of the Message-ID
header because, if I comment out that line, the code works. Of course,
without that line, the email is delivered, but no alert is created.

Any thoughts?
 
Top