H
hchristou
Hello,
I am trying to write a simple program in VB.NET that connects an
outlook exchange server and reads through the emails of a specific
user account. However as I need this code to run in the background it
cannot prompt the user for any login credentials.
I have written the following which seems to work well with the
exception of prompting the user for their username and password..
which I cannot seem to get rid of... please help!!!
BTW - this code utlizes outlook redemption so to avoid security
messages being displayed.
You can assume that the login credentials are known (say L:
(e-mail address removed) Password123)
Imports Redemption
Imports MSMAPI
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button1.Click
CheckExchangeEmail()
End Sub
Private Sub CheckExchangeEmail()
Const olFolderInbox As Redemption.rdoDefaultFolders = 6
Dim Session As New Redemption.RDOSession
Dim objFolder As Redemption.RDOFolder
Dim oItems As Object
Dim oItem As Redemption.RDOMail
Dim sMessageBody As String
Try
'This is the line that prompts me for login credentials
Session.LogonExchangeMailbox("(e-mail address removed)",
"myexchangeserver")
objFolder = Session.GetDefaultFolder(olFolderInbox)
oItems = objFolder.Items
For Each oItem In oItems
sMessageBody = oItem.Body
MsgBox(sMessageBody)
Next
Catch ex As Exception
Session = Nothing
Finally
If Not IsNothing(Session) Then
If Session.LoggedOn Then
Session.Logoff()
End If
End If
End Try
End Sub
End Class
I am trying to write a simple program in VB.NET that connects an
outlook exchange server and reads through the emails of a specific
user account. However as I need this code to run in the background it
cannot prompt the user for any login credentials.
I have written the following which seems to work well with the
exception of prompting the user for their username and password..
which I cannot seem to get rid of... please help!!!
BTW - this code utlizes outlook redemption so to avoid security
messages being displayed.
You can assume that the login credentials are known (say L:
(e-mail address removed) Password123)
Imports Redemption
Imports MSMAPI
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button1.Click
CheckExchangeEmail()
End Sub
Private Sub CheckExchangeEmail()
Const olFolderInbox As Redemption.rdoDefaultFolders = 6
Dim Session As New Redemption.RDOSession
Dim objFolder As Redemption.RDOFolder
Dim oItems As Object
Dim oItem As Redemption.RDOMail
Dim sMessageBody As String
Try
'This is the line that prompts me for login credentials
Session.LogonExchangeMailbox("(e-mail address removed)",
"myexchangeserver")
objFolder = Session.GetDefaultFolder(olFolderInbox)
oItems = objFolder.Items
For Each oItem In oItems
sMessageBody = oItem.Body
MsgBox(sMessageBody)
Next
Catch ex As Exception
Session = Nothing
Finally
If Not IsNothing(Session) Then
If Session.LoggedOn Then
Session.Logoff()
End If
End If
End Try
End Sub
End Class