aspNetEmail

HtmlUtility.IsAlive Method 

Checks for a successful response from a URL.

public bool IsAlive(
   string url
);

Parameters

url
Url to check.

Return Value

Remarks

This method makes a HEAD request to see if a resource is alive.

Example

[C#]
            HtmlUtility utility = new HtmlUtility();
            string url = "http://www.microsoft.com";
            
            //check to see if the url is alive
            if( utility.IsAlive( url ) )
            {
            	//convert linked css sheets to inline <style> content
            	utility.CssOption = CssOption.EmbedLinkedSheets;
            
            
            	utility.LoadUrl( url );
            
            
            	//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();
            }
            
            
[VB.NET]
            Dim utility As New HtmlUtility()
            
            Dim url As String = "http://www.microsoft.com"
            
            'check to see if the url is alive
            If utility.IsAlive(url) Then
               'convert linked css sheets to inline <style> content
               utility.CssOption = CssOption.EmbedLinkedSheets
               
               
               utility.LoadUrl(url)
               
               
               '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 If
            
            

See Also

HtmlUtility Class | aspNetEmail Namespace