473,401 Members | 2,068 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,401 software developers and data experts.

VB.NET program to monitor emails on exchange server

seraieis
Good afternoon all!

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
  1.         Dim server As New System.Net.Mail.SmtpClient("STHEMB002", 25)
  2.         Dim msg As New System.Net.Mail.MailMessage()
  3.  
  4.         msg.To.Add("Bob.Dole@company.com")
  5.         msg.From = New System.Net.Mail.MailAddress("Bob.Dole@company.com")
  6.         msg.Subject = "test"
  7.  
  8.         server.DeliveryMethod = Net.Mail.SmtpDeliveryMethod.Network
  9.         server.UseDefaultCredentials = False
  10.         server.Credentials = New System.Net.NetworkCredential("user", "pass", "STHEMB002")
  11.  
  12.         server.Send(msg)
  13.  
I know that within outlook, the mailbox requires password authentication, so I tried to add a crediential before sending, however the "server.Send(msg)" line generates the following error:
Expand|Select|Wrap|Line Numbers
  1. System.Net.Mail.SmtpException was unhandled
  2.   Message="Failure sending mail."
  3.   Source="System"
  4.   StackTrace:
  5.        at System.Net.Mail.SmtpClient.Send(MailMessage message)
  6.  
If anyone has any suggestions, I'd love to listen! I've only messed with Outlook and COM functions, and I haven't done anything like this, so I'm not even sure where to start.

Thanks!
Feb 24 '09 #1
3 6858
It's been about a year since I dealt with exchange, but I thought that credentials were necessary only if :

1) the user you want to login as is not the user that is currently logged in
or
2) the server configuration requires a special userid and password combination

I would check active directory and stuff a "real" user account and password into your credential field or login as a valid AD user and try it again. Assuming you have tried this, verify your network connectivity/server configuration by using Telnet to connect via SMTP/TCP.
Here is how...
from CMD prompt: telnet servername tcpportnumber
then: HELO yourfulldomainname.com
then: mail from:<sender@domain.com>
then: rcpt to:<recipient@domain.com>
then: data
then: Subject: and a subject if you want
then: Any kind of message text
then: .

A blank line with a period ends the message. If you get through all of those commands and get a message accepted statement from the server, then the problem is within your code/use of the SMTPClient class.
Feb 25 '09 #2
@stoogots2
I followed the steps you suggested, however I was unable to use telnet. It keeps giving me an error along the lines of "HELO isn't a valid command".

I also tried using CDO to connect to the exchange server (using my user id and password) and was unsuccessful. There has to be something I'm missing, however I'm not sure what it is. Are there any other ports that Exchange uses to send/receive email?
Feb 25 '09 #3
The ports are all configurable at the server.

If ...
"telnet servername 25"
did not give you a line of text at the top of the screen in your telnet session, then your SMTPClient will not work. I don't know how your got that "unrecognized command" unless you were at a CMD prompt when you typed it. The command in quotes should open a session with the server (just as if you were another smtp server across the network). It should give you a number on the top left of the screen and if it is 500, you got an error that necessitates talking with your exchange admins. There should be a blinking cursor, not another C:\> prompt. You might need to make a request to become a relay to the server (they generally get your IP or hostname and put it into an allowed list).



you don't get a line of text at the top of the screen?
It sounds like a server config thing if that is the case. You must be able to ping by IP address
Feb 25 '09 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: Stuart Mueller | last post by:
I have an exchange server, that I sometimes use to perform mail shots to clients on our database, these can be upwards of 1000 at a time. As we don't want different clients to see who we are...
0
by: Jo | last post by:
Hi, What I need to do is be able to look at a certain folder on the mail exchange server and read/view the emails in it. I then need to be able to move the emails I've looked at to another...
3
by: Jishnu | last post by:
Hi ASP Gurus out there, I have question. I am wondering if any one can guide me towards a script that can handle bounced emails from a newsletter campaign. I am not interested in .Net solution....
7
by: Bruce MacDonald | last post by:
I am unable to see the health monitor SQL table functions (e.g.: SQLPROC.HEALTH_CONT_HI). Have I missed a utility which registers the functions? DB2 8.1.3.132 WR21324. Another point about the...
7
by: Razzie | last post by:
Hey all, I need to connect to an SMTP server and get a notification when it gets a new mail to send. I want to be able to 'read' that email (retrieve recipient information for example). Is that...
2
by: Dave Smithz | last post by:
Hi there, I need to build a database that also handles emails. That is, the database is a customer list database and there is quite a lot of contact with the customers through email. We want all...
2
by: Rich Wallace | last post by:
Is there a way I can monitor an Exchange email account via .NET? I want to write a Windows Service that monitors an email account for a specific message with an attachment sent into the office and...
3
by: John | last post by:
Hi I have a vb.net win form app that runs on a MS Small Business Server 2003 (windows 20003 server + ISA 2000 + exchange 2000). My question is how can I send external emails from the app via...
0
by: =?Utf-8?B?UmljaA==?= | last post by:
Hello, My company will be hosting a webcast, and I need to send out 2000 individual emails to people who signed up (for login information...). I created an smtp app that I can loop through...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.