473,661 Members | 2,431 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Reading email from Exchange

I can't seem to retrieve messages that are not in my mailbox from Exchange.

If I am reading mail from my Exchange server, I will get messages that are
in my inbox that have already been read but not deleted (outlook).

What I am trying to get are messages that haven't been read yet?

Is there a way to do this?

Here is the code I am using.

The problem with this code is that I am getting the very first email in my
inbox (back to 10/15/2004).

*************** *************** *************** ******
Dim tcpClient As TcpClient = New TcpClient
Dim hostName As String = "MyServer.c om"
Dim userName As String = "tts"

Dim userPassword As String = "ac1234"
Dim messageNumber As String = "1"
Dim returnMessage As String
Dim sTemp As String

Try
tcpClient.Conne ct(hostName, 110)
Dim networkStream As NetworkStream = tcpClient.GetSt ream()
Dim bytes(tcpClient .ReceiveBufferS ize) As Byte
Dim sendBytes As Byte()

networkStream.R ead(bytes, 0, CInt(tcpClient. ReceiveBufferSi ze))

sendBytes = Encoding.ASCII. GetBytes("User " + userName + vbCrLf)
networkStream.W rite(sendBytes, 0, sendBytes.Lengt h)

sTemp = networkStream.R ead(bytes, 0, CInt(tcpClient. ReceiveBufferSi ze))

sendBytes = Encoding.ASCII. GetBytes("Pass " + userPassword + vbCrLf)
networkStream.W rite(sendBytes, 0, sendBytes.Lengt h)

sTemp = networkStream.R ead(bytes, 0, CInt(tcpClient. ReceiveBufferSi ze))

sendBytes = Encoding.ASCII. GetBytes("STAT" + vbCrLf)
networkStream.W rite(sendBytes, 0, sendBytes.Lengt h)

sTemp = networkStream.R ead(bytes, 0, CInt(tcpClient. ReceiveBufferSi ze))

sendBytes = Encoding.ASCII. GetBytes("RETR " + messageNumber + vbCrLf)
networkStream.W rite(sendBytes, 0, sendBytes.Lengt h)

Thread.Sleep(50 0)

networkStream.R ead(bytes, 0, CInt(tcpClient. ReceiveBufferSi ze))
returnMessage = Encoding.ASCII. GetString(bytes )
EmailContent.Te xt = returnMessage

sendBytes = Encoding.ASCII. GetBytes("QUIT" + vbCrLf)
networkStream.W rite(sendBytes, 0, sendBytes.Lengt h)

tcpClient.Close ()
Catch ex As Exception
EmailContent.Te xt = "Could not retrieve email or your inbox is empty"
End Try
*************** *************** *************** ***********

Thanks,

Tom
Jan 26 '07 #1
0 1369

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
10576
by: jeff | last post by:
Hi. I am trying to read addresses from an Exchange 5.5 Global Address Book from an asp.net page. When the page executes the error "Collaboration Data Objects - ]" is generated. Here is the code: Dim strProfileInfo As String Dim ObjSession As New MAPI.Session
1
1791
by: Brian Henry | last post by:
Does anyone know how to send an email to an internal exchange server (internal email only, how you can send email to a username in active directory in exchange with out a domain (@domain.com) after it..) from vb.net with out useing smtp? because some exchange servers actually dont use SMTP because they are internal only... if you know what I mean, do you know how to do this from VB.net to send to an internal user? thanks! --...
2
13680
by: mark wheeler via .NET 247 | last post by:
I have a requirement whereby I need to read the contents &attachments of email sent to an account in exchange server2003. The email details (sender, attachment file names, date, etc) areto be stored into a SQL server 2000 database and the fileattachment(s) are copied to a specified location. Theapplication is to be written using visual studio.net (C#). Exchange server sits on one server, my appliaction will run as aservice on another server. ...
4
5365
by: Jason | last post by:
Hi all I have wrote a small email client that checks POP3 email (using username and password). this work fine. I would now like to add the functionality to check email on an exchange server, that is to use the NT username at that moment, connect to the local exchange server and then pull the email "off" the exchange server. pull it off, as in the email is deleted off the exchange server. preferably to pull it off the exchange server in...
0
1386
by: Jayme | last post by:
My company would like to implement an online calendar that integrates with our current website that would allow our clients to view upcoming workshops and events. These "appointments" are currently entered by the event coordinators into a public calendar on our Exchange 2000 server. Our Exchange 2000 server and our Internet server exist on two different machines and a solution cannot consist of a "server" program that resides on the...
3
2076
by: Curt_C [MVP] | last post by:
Hey all, I can't seem to find a good link to reading an Exchange (2000) calendar with ASP.NET 1.1 Anyone got a good pointer/starter/link? Thanks -- Curt Christianson site: http://www.darkfalz.com
10
7174
by: bobBaker | last post by:
Does anybody know of a good way to get a list of emails from the corporate exchange server from a corporate website?
0
1289
by: tshad | last post by:
I can't seem to retrieve messages that are not in my mailbox from Exchange. If I am reading mail from my Exchange server, I will get messages that are in my inbox that have already been read but not deleted (outlook). What I am trying to get are messages that haven't been read yet? Is there a way to do this? Here is the code I am using.
4
1837
by: John | last post by:
Hi Outlook 2003 connected with exchange server. A user is logged in to the client pc. Is it possible to programmatically get the user's email address that is set on the 'Email Addresses' tab of the exchange server? Thanks
0
8432
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8758
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8545
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7364
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6185
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5653
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4179
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4346
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1743
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.