|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
WSS document event handler that will use System.web.mail sendmailI have a WSS document event handler that works on a document insert, I want to use system.web.mail to get to sendmail and put out an email. Document event handlers are written with C# class library which does not allow me to reference system.web.mail. I use use the interface with a web control and reference the web control from within the document event class but when I compile I get c:\Documents and Settings\cmello\My Documents\Visual Studio Projects\SISWorkflow\bin\Debug\SendMailCtrl.dll Referenced class 'SendMailCtrl.DocLibSendMail' has base class or interface 'System.Web.UI.WebControls.WebControl' defined in an assembly that is not referenced. You must add a reference to assembly 'System.Web'. I am thinking that is because in the SendMailCtrl dll there is a method that uses SendMail and the reference to System.web.mail inside the web control project is the reason that I cannot create a new instance of the web control object in my C# document event library and call the method to send mail. Help!! please I need to have a document library insert event send my custom email to users who have alerts set without having to go into CAML and rewrite the alert notification AARGH -- cindy Hello,
I are not very clear on what you said about: Document event handlers are written with C# class library which does not allow me to reference system.web.mail. Even in a class library project, we can still add a reference to System.Web.Dll and use System.Web.Mail.MailMessage. For example, you can open the class library project in VS.NET 2003, right click the project in solution explorer and select "add reference" and add "System.Web.DLL". Then, in its code, you can use: System.Web.Mail.MailMessage m= new System.Web.Mail.MailMessage(); Sincerely, Luke Zhang Microsoft Online Community Support ================================================== Get notification to my posts through email? Please refer to http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif ications. Note: The MSDN Managed Newsgroup support offering is for non-urgent issues where an initial response from the community or a Microsoft Support Engineer within 1 business day is acceptable. Please note that each follow up response may take approximately 2 business days as the support professional working with you may need further investigation to reach the most efficient resolution. The offering is not appropriate for situations that require urgent, real-time or phone-based interactions or complex project analysis and dump analysis issues. Issues of this nature are best handled working with a dedicated Microsoft Support Engineer by contacting Microsoft Customer Support Services (CSS) at http://msdn.microsoft.com/subscriptions/support/default.aspx. ================================================== This posting is provided "AS IS" with no warranties, and confers no rights. using System;
using System.Security.Principal; using System.Runtime.InteropServices; using Microsoft.SharePoint; using System.Data.SqlClient; using System.Collections; using System.Data; using System.Web; namespace DocLibEventHandler { public class DocVersionHandler : IListEventSink { SqlConnection connection = new SqlConnection("Data Source=; Initial Catalog=sis_sts_content; uid=; pwd=;"); Hashtable MyTable = new Hashtable(); void IListEventSink.OnEvent(Microsoft.SharePoint.SPListEvent listEvent) { WindowsImpersonationContext wic = CreateIdentity("", "", "").Impersonate(); if (listEvent.Type == SPListEventType.Insert) { SPWeb site = listEvent.Site.OpenWeb(); SPFile file = site.GetFile(listEvent.UrlAfter); string x = file.ServerRelativeUrl.ToString(); string z = file.ModifiedBy.ToString(); MyTable = file.Properties; string xkey = ""; if (MyTable.Count != 0) xkey = MyTable["Abstract"].ToString(); SPUserCollection users = site.Users; foreach (SPUser user in users) { SPAlertCollection alerts = user.Alerts; foreach (SPAlert alert in alerts) { if (alert.ListID==listEvent.ListID) { if (alert.AlertFrequency == Microsoft.SharePoint.SPAlertFrequency.Weekly) { ////////ERROR System.Web.Mail.MailMessage m= new System.Web.Mail.MailMessage(); }}}}}} wic.Undo();} see error line ////ERROR error in compile is C:\Documents and Settings\cmello\My Documents\Visual Studio Projects\DocLibHandler\DocVersionHandler.cs(49): The type or namespace name 'Mail' does not exist in the class or namespace 'System.Web' (are you missing an assembly reference?) -- Show quotecindy "Luke Zhang [MSFT]" wrote: > Hello, > > I are not very clear on what you said about: > > Document event handlers are written with C# class library which does not > allow me to reference system.web.mail. > > Even in a class library project, we can still add a reference to > System.Web.Dll and use System.Web.Mail.MailMessage. For example, you can > open the class library project in VS.NET 2003, right click the project in > solution explorer and select "add reference" and add "System.Web.DLL". > Then, in its code, you can use: > > System.Web.Mail.MailMessage m= new System.Web.Mail.MailMessage(); > > Sincerely, > > Luke Zhang > > Microsoft Online Community Support > ================================================== > Get notification to my posts through email? Please refer to > http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif > ications. > > Note: The MSDN Managed Newsgroup support offering is for non-urgent issues > where an initial response from the community or a Microsoft Support > Engineer within 1 business day is acceptable. Please note that each follow > up response may take approximately 2 business days as the support > professional working with you may need further investigation to reach the > most efficient resolution. The offering is not appropriate for situations > that require urgent, real-time or phone-based interactions or complex > project analysis and dump analysis issues. Issues of this nature are best > handled working with a dedicated Microsoft Support Engineer by contacting > Microsoft Customer Support Services (CSS) at > http://msdn.microsoft.com/subscriptions/support/default.aspx. > ================================================== > > This posting is provided "AS IS" with no warranties, and confers no rights. > > > > Hello Cindy,
Have you added a reference to System.Web.DLL to the project? If so, you may right click the reference in solution explorer, and check its version information. Is it 1.0.5000.0, or something else? I have test this in VS.NET 2003 and .NET framework 1.1 and it seems there is no such a problem. You may check the reference as I suggested above. Normally, such a problem also be with the reference and version. Sincerely, Luke Zhang Microsoft Online Community Support This posting is provided "AS IS" with no warranties, and confers no rights. Hello Cindy,
Any update on this issue/ Have you checked the reference and its version as I suggested? Sincerely, Luke Zhang Microsoft Online Community Support This posting is provided "AS IS" with no warranties, and confers no rights. I am using visual studio 1.1
-- Show quotecindy "Luke Zhang [MSFT]" wrote: > Hello, > > I are not very clear on what you said about: > > Document event handlers are written with C# class library which does not > allow me to reference system.web.mail. > > Even in a class library project, we can still add a reference to > System.Web.Dll and use System.Web.Mail.MailMessage. For example, you can > open the class library project in VS.NET 2003, right click the project in > solution explorer and select "add reference" and add "System.Web.DLL". > Then, in its code, you can use: > > System.Web.Mail.MailMessage m= new System.Web.Mail.MailMessage(); > > Sincerely, > > Luke Zhang > > Microsoft Online Community Support > ================================================== > Get notification to my posts through email? Please refer to > http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif > ications. > > Note: The MSDN Managed Newsgroup support offering is for non-urgent issues > where an initial response from the community or a Microsoft Support > Engineer within 1 business day is acceptable. Please note that each follow > up response may take approximately 2 business days as the support > professional working with you may need further investigation to reach the > most efficient resolution. The offering is not appropriate for situations > that require urgent, real-time or phone-based interactions or complex > project analysis and dump analysis issues. Issues of this nature are best > handled working with a dedicated Microsoft Support Engineer by contacting > Microsoft Customer Support Services (CSS) at > http://msdn.microsoft.com/subscriptions/support/default.aspx. > ================================================== > > This posting is provided "AS IS" with no warranties, and confers no rights. > > > > |
|||||||||||||||||||||||