473,721 Members | 2,224 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 1375

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

Similar topics

7
10579
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
1797
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
13684
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
5372
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
1387
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
2086
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
7178
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
1290
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
1838
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
8736
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9373
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9227
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...
0
8016
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
6676
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
5992
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
4491
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
4761
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3201
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.