Hi GUys,
After a few years away from programming i have dusted of visual studio and have got back in to it
What i am doing is logging in to my pop3 account to retrieve the emails, i have added an association with openpop.net: OpenPop.NET | Free Communications software downloads at SourceForge.net
My current code is:
I seem to be getting a few erros which is mainly:
"Session' is not declared. It may be inaccessible due to its protection level."
I have googled about but can't seem to find a solution, any help would be appreciated
thanks guys
Graham
After a few years away from programming i have dusted of visual studio and have got back in to it
What i am doing is logging in to my pop3 account to retrieve the emails, i have added an association with openpop.net: OpenPop.NET | Free Communications software downloads at SourceForge.net
My current code is:
VB.NET:
Imports OpenPop.Pop3
Imports OpenPop.Mime
Imports System.Data
Public Class formMain
Private Sub mainForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Protected Sub Read_Emails(ByVal sender As Object, ByVal e As EventArgs)
Dim pop3Client As Pop3Client
If (Session("Pop3Client") Is Nothing) Then
pop3Client = New Pop3Client
pop3Client.Connect(txtMailServer.Text, Integer.Parse(txtPort.Text), chkSSL.Checked)
pop3Client.Authenticate(txtUserName.Text, txtPassword.Text)
Session("Pop3Client") = pop3Client
Else
pop3Client = CType(Session("Pop3Client"), Pop3Client)
End If
Dim count As Integer = pop3Client.GetMessageCount
Dim dtMessages As DataTable = New DataTable
dtMessages.Columns.Add("MessageNumber")
dtMessages.Columns.Add("From")
dtMessages.Columns.Add("Subject")
dtMessages.Columns.Add("DateSent")
Dim counter As Integer = 0
Dim i As Integer = count
Do While (i >= 1)
Dim message As Message = pop3Client.GetMessage(i)
dtMessages.Rows.Add()
dtMessages.Rows((dtMessages.Rows.Count - 1))("MessageNumber") = i
dtMessages.Rows((dtMessages.Rows.Count - 1))("From") = message.Headers.From.Address
dtMessages.Rows((dtMessages.Rows.Count - 1))("Subject") = message.Headers.Subject
dtMessages.Rows((dtMessages.Rows.Count - 1))("DateSent") = message.Headers.DateSent
counter = counter + 1
i = i - 1
If counter = 5 Then
Exit Do
End If
Loop
gvEmails.DataSource = dtMessages
gvEmails.DataBind()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles getMailButton.Click
End Sub
End Class
I seem to be getting a few erros which is mainly:
"Session' is not declared. It may be inaccessible due to its protection level."
I have googled about but can't seem to find a solution, any help would be appreciated
thanks guys
Graham