I'm having trouble here, and I've visited about half the sites on the internet to fix it, and I'm not having luck.
I'm trying to write a VB.NET application that will monitor an exchange server mailbox and download any attachments in received messages. However, I cannot find a way to connect to the server.
This is what I have to far:
Expand|Select|Wrap|Line Numbers
- Dim server As New System.Net.Mail.SmtpClient("STHEMB002", 25)
- Dim msg As New System.Net.Mail.MailMessage()
- msg.To.Add("Bob.Dole@company.com")
- msg.From = New System.Net.Mail.MailAddress("Bob.Dole@company.com")
- msg.Subject = "test"
- server.DeliveryMethod = Net.Mail.SmtpDeliveryMethod.Network
- server.UseDefaultCredentials = False
- server.Credentials = New System.Net.NetworkCredential("user", "pass", "STHEMB002")
- server.Send(msg)
Expand|Select|Wrap|Line Numbers
- System.Net.Mail.SmtpException was unhandled
- Message="Failure sending mail."
- Source="System"
- StackTrace:
- at System.Net.Mail.SmtpClient.Send(MailMessage message)
Thanks!