vb.net 2005 smtp is great, need help on proxy please
Hi,
got the template manager in fantastic shape its big and has batch runs as well with huge amounts of code, thanks to you.
but
we have a last part of this to send email through the proxy at work in exchange for it to all run right, we usually use the xp_sendmail in sql server which is operating so we know we can send mail to exchange from things, any suggestion ?
This old external smtp server works fine:
Dim mail As New MailMessage()
mail.From = New MailAddress("[email protected]")
mail.To.Add("[email protected]")
mail.Subject = "test subject line"
Dim mailcontenturl As String = "http://www.google.com/"
mail.Body = GetHTML(mailcontenturl)
mail.IsBodyHtml = True
Dim smtp As New SmtpClient()
smtp.Credentials = New System.Net.NetworkCredential("[email protected]", "password")
smtp.Port = 587
smtp.Host = "smtp.domain.com"
smtp.Send(mail)
MsgBox("Mail Sent")
Private Function GetHTML(ByVal url As String) As String
Dim wReq As WebRequest = System.Net.HttpWebRequest.Create(url)
Dim sr As New StreamReader(wReq.GetResponse().GetResponseStream())
Dim result As String = sr.ReadToEnd()
sr.Close()
Return result
End Function
This does not:
Dim mail As New MailMessage()
mail.From = New MailAddress("[email protected]")
mail.To.Add("[email protected]")
mail.Subject = "test subject line"
Dim mailcontenturl As String = "http://www.google.com/"
mail.Body = GetHTML(mailcontenturl)
mail.IsBodyHtml = True
Dim smtp As New SmtpClient()
Dim ws As New System.Net.WebClient
Dim ProxyObject As New WebProxy("http://192.168.1.1:8080/", True)
Dim cred As New NetworkCredential("domain\test", "password", "domain.com")
ws.Proxy = ProxyObject
smtp.Port = 25
smtp.Host = "mail.domain.com" '// exchange server
smtp.Send(mail)
Private Function GetHTML(ByVal url As String) As String
Dim wReq As WebRequest = System.Net.HttpWebRequest.Create(url)
Dim sr As New StreamReader(wReq.GetResponse().GetResponseStream())
Dim result As String = sr.ReadToEnd()
sr.Close()
Return result
End Function
keep getting that 407 proxy credentials required, do you have any thoughts on this code, thanks
is there any way to send mail using the exchange server name like this ?
smtp.Host = "ExchangeServer.Local.com"
we have xp_sendmail working on the ms sql server inside of stored procedures, is there a way to use that here ? thanks.
Re: vb.net 2005 smtp is great, need help on proxy please
so it looks like the network cred will automatically use what is provided as 'Proxy'
Dim ws As New System.Net.WebClient
Dim ProxyObject As New WebProxy("http://X.X.X.X:XXXX/", True)
ws.Proxy = ProxyObject
Whats confusing is that there needs to be a credential for the proxy and one for smtp if its different. Im not sure , does anyone know who to name it using with such as:
Dim cr As New System.Net.NetworkCredential("user", "pwd", "MyDomain")
cr(ws.Proxy) = ProxyObject or is it
ws.Proxy = cr.ProxyObject
the only thing left is:
"cannot connect to remote server" "No connection could be made because the target machine actively refused it."
which our admin is taking care of.