Friday, February 17, 2006

How to check Internet Connection using .Net

In this article I want to describe how to check Internet Connection using .Net.
We use an API function to check the connection; InternetGetConnectionState.

The function source code is described below:

Private Declare Function InternetGetConnectedState Lib "wininet.dll" (ByRef lpdwFlags As Int32, _
ByVal dwReserved As Int32) As Boolean

Public Function IsConnectionAvailable() As Boolean
Dim lngFlags As Long
Try
'Return True if connection is available
IsConnectionAvailable = InternetGetConnectedState(lngFlags, 0)
Catch ex As Exception
Throw ex
End Try
End Function

2 comments:

Anup said...

Hi sir,

I am able to access the mailboxes of the Exchange server 2003 by using the Active Directory Services.
Now i need to access the mails from the inbox of each mailboxes using C# and CDO or CDOEXM.

I have searched a lot on the NET but i dint got any usefull information.

Kindly provide me some dynamic code through which i can access each mailboxes by using their URL's and than iterate through each folders and than each mail items of the folder.

Kindly help me out as i have been searching from past 1 week.

If i get the way to access them dynamically than it will be a great help for me.

Thanks a lot in advance.

Anup said...

I also wanna ask a query...

As i have read the MSDN about the CDO and CDOEXM library, which provide few interfaces like IMessages, IMessage and IMailBox interfaces and many more.....

Can we access the content using these interfaces or shall we require some ADODB connectivity and than fire the queries on the mailbox and than access the data.

If we use CDO classes and interfaces than how shall we use them to access the data using C# language?

or

If we use the ADODB than how to procees further and than after accessing the items how to get the properties of the item like Subjectname, Sender mail id and so on...

I am really bit confused about these queries....

Kindly
clear my doubts.....

Thanks....