Credentials used to download http:// or https:// Html code.
[C#]
EmailMessage m = new EmailMessage("mail.mycompany.com");
m.FromAddress = "me@mycompany.com";
m.To = "you@yourcompany.com";
m.Subject = "testing password protected site";
HtmlUtility util = new HtmlUtility( m );
//create and add new credentials
string privateUrl = "http://www.privatesite.com/";
//if we wanted to use the default credentials, being used to execute this code, simply uncomment the following line
//util.Credentials = CredentialCache.DefaultCredentials;
//or else, we can manully create and add them
CredentialCache cc = new CredentialCache();
cc.Add( new Uri( privateUrl ), "Basic", new NetworkCredential( "myusername", "secretpassword" ) );
util.Credentials = cc;
util.LoadUrl( privateUrl );
util.Render();
m.BodyFormat = MailFormat.Html;
m.Body = util.RenderedHtmlContent;
m.Send();
[VB.NET]
Dim m As New EmailMessage("mail.mycompany.com")
m.FromAddress = "me@mycompany.com"
m.To = "you@yourcompany.com"
m.Subject = "testing password protected site"
Dim util As New HtmlUtility(m)
'create and add new credentials
Dim privateUrl As String = "http://www.privatesite.com/"
'if we wanted to use the default credentials, being used to execute this code, simply uncomment the following line
'util.Credentials = CredentialCache.DefaultCredentials
'or else, we can manully create and add them
Dim cc As New CredentialCache()
cc.Add(New Uri(privateUrl), "NTLM", New NetworkCredential("myusername", "secretpassword"))
util.Credentials = cc
util.LoadUrl(privateUrl)
util.Render()
m.BodyFormat = MailFormat.Html
m.Body = util.RenderedHtmlContent
m.Send()