aspNetEmail

CreateEmbeddedObjectEventHandler Delegate

The delegate used for event handling.

public delegate void CreateEmbeddedObjectEventHandler(
   object sender,
   CreateEmbeddedObjectEventArgs e
);

Example

[C#]
            private void EmailWebPage()
            {
            	HtmlUtility utility = new HtmlUtility();
            	string url = "http://www.microsoft.com";
            
            	//wire up the events
            	utility.BeforeWebRequest += new BeforeWebRequestEventHandler( OnBeforeWebRequest );
            	utility.CreateEmbeddedObject += new CreateEmbeddedObjectEventHandler( OnCreateEmbeddedObject );
            
            
            	//convert linked css sheets to inline <style> content
            	utility.CssOption = CssOption.EmbedLinkedSheets;
            
            	utility.LoadUrl( url );
            
            	//set the UrlContent base
            	utility.SetUrlContentBase = true;
            
            	//set the basetag in the html
            	utility.SetHtmlBaseTag = true;
            
            	//embed the images
            	utility.EmbedImageOption  = EmbedImageOption.ContentLocation;
            
            	//render the Html so it is properly formatted for email
            	utility.Render();
            
            	//create an EmailMessage with appropriate text and html parts
            	EmailMessage email = utility.ToEmailMessage();
            
            	//load To, From, Server, etc... values from the web.config
            	email.LoadFromConfig();
            
            	email.Subject = "Html Utility Test";
            
            	email.Send();
            
            }
            
            private void OnBeforeWebRequest( object sender, BeforeWebRequestEventArgs e )
            {
            	//if we wanted access to the webrequest object, we could get it here
            	//e.WebRequest
            
            	Console.WriteLine( "OnBeforeWebRequest called." );
            }
            
            private void OnCreateEmbeddedObject( object sender, CreateEmbeddedObjectEventArgs e )
            {
            	//here we get access to the embedded object, in case we want to change any properties
            	//e.EmbeddedObject
            
            	Console.WriteLine( "Creating embedded object with name: " + e.EmbeddedObject.Name );
            }
            
            
[VB.NET]
            Private Sub EmailWebPage()
               Dim utility As New HtmlUtility()
               Dim url As String = "http://www.microsoft.com"
               
               'wire up the events
               AddHandler utility.BeforeWebRequest, AddressOf OnBeforeWebRequest
               AddHandler utility.CreateEmbeddedObject, AddressOf OnCreateEmbeddedObject
               
               
               'convert linked css sheets to inline <style> content
               utility.CssOption = CssOption.EmbedLinkedSheets
               
               utility.LoadUrl(url)
               
               'set the UrlContent base
               utility.SetUrlContentBase = True
               
               'set the basetag in the html
               utility.SetHtmlBaseTag = True
               
               'embed the images
               utility.EmbedImageOption = EmbedImageOption.ContentLocation
               
               'render the Html so it is properly formatted for email
               utility.Render()
               
               'create an EmailMessage with appropriate text and html parts
               Dim email As EmailMessage = utility.ToEmailMessage()
               
               'load To, From, Server, etc... values from the web.config
               email.LoadFromConfig()
               
               email.Subject = "Html Utility Test"
               
               email.Send()
            End Sub 'EmailWebPage
             
            
            Private Sub OnBeforeWebRequest(sender As Object, e As BeforeWebRequestEventArgs)
               'if we wanted access to the webrequest object, we could get it here
               'e.WebRequest
               Console.WriteLine("OnBeforeWebRequest called.")
            End Sub 'OnBeforeWebRequest
            
            
            Private Sub OnCreateEmbeddedObject(sender As Object, e As CreateEmbeddedObjectEventArgs)
               'here we get access to the embedded object, in case we want to change any properties
               'e.EmbeddedObject
               Console.WriteLine("Creating embedded object with name: " + e.EmbeddedObject.Name)
            End Sub 'OnCreateEmbeddedObject
            

Requirements

Namespace: aspNetEmail

Assembly: aspNetEmail (in aspNetEmail.dll)

See Also

aspNetEmail Namespace