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:
ha...@test.com P: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("ha...@test.com",
"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
--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
<hchr...@ulysses-systems.com> wrote in message
news:03b0d4d0-66c0-4e8e...@b1g2000hsg.googlegroups.com...
Thanks for the quick reply (and appologies for the mutliple posts).
Are you saying that it is not possible to have a service connecting to
an exchange server to scan the inbox of anybody other than the
currently logged in user? Even in the case where we have the target
users login and password at hand?
I was hoping that it would be possible to have a service sitting on
the server scanning mulitple users e-mails.
thanks
Harry
You'll want to have the credentials of a "master user" who has
permissions to read all the users' mail that needs to be processed.
thankyou for the help :)
--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
<hchr...@ulysses-systems.com> wrote in message
news:e429aed7-be77-43b2...@26g2000hsk.googlegroups.com...
--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"Hannes de Jager" <Hannes de Ja...@discussions.microsoft.com> wrote in
message news:80ECCB59-CB7C-44A0...@microsoft.com...
I can access the GAL using Session.AddressBook.AddressLists("Global Address
List") like you suggested.
By remotely I meant from a different machine than my exchange server.
I'm running Exchange 2007.
session = new RDOSession();
session.logonExchangeMailbox("Admini...@attix5vm.com",
"HDJ-VM-EXCG07");
System.out.println("GAL Item Count: " +
session.getAddressBook().addressLists(new Variant("Global Address
List")).getCount());
System.out.println("Logged On?: " + session.getLoggedOn());
session.getStores().getSharedMailbox(new
Variant("Administrator")).getIPMRootFolder();
From which I get the following output:
GAL Item Count: 0
Logged On?: true
Exception in thread "main" com.jacob.com.ComFailException: Invoke of:
GetSharedMailbox
Source: Redemption.RDOStores
Description: Could not open the GAL container
--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"Hannes de Jager" <Hannes...@discussions.microsoft.com> wrote in message
news:C154580A-93E3-484A...@microsoft.com...
--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"Hannes de Jager" <Hannes...@discussions.microsoft.com> wrote in message
news:A3006970-7397-49E0...@microsoft.com...
I have a problem with LogonExchangeMailbox in a service.
This c++ code works with no prompts (runned under the box owner) in a
standart application:
CoInitialize(NULL);
hr = CoCreateInstance ( CLSID_RDOSession,
NULL,
CLSCTX_INPROC_SERVER,
IID_IRDOSession,
(void**) &RDOSession );
RDOSession->LogonExchangeMailbox( WideString( strUSer ),
WideString( strServerName ));
//...
but in a service (runned as the same user), it seems to block on
LogonExchangeMailbox.
I don't know where is the problem.
an idea ?
--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"Gilles" <Gil...@discussions.microsoft.com> wrote in message
news:1A7C460D-866A-4FEE...@microsoft.com...
After some tests with this piece of code :
TStringList *strlLog = NULL;
IRDOSession* RDOSession = NULL;
IRDOStore* RDOMailBoxStore = NULL;
IRDOFolders* RDOFolders = NULL;
bool bOk = true;
try
{
//logs
strlLog = new TStringList();
//init COM
HRESULT res = CoInitialize(NULL);
if ( (res == S_OK) || (res == S_FALSE) )
{
HRESULT hr = NULL;
strlLog->Add("CoCreateInstance...");
hr = CoCreateInstance ( CLSID_RDOSession, NULL, CLSCTX_INPROC_SERVER,
IID_IRDOSession,
(void**) &RDOSession );
if ( !SUCCEEDED ( hr ) )
{
bOk = false;
strlLog->Add("error COM CoGetClassObject.");
}
if ( bOk )
{
strlLog->Add("LogonExchangeMailbox...");
RDOSession->LogonExchangeMailbox( WideString( "gilles" ),
WideString( "exch1" ));
if( !RDOSession->LoggedOn )
{
bOk = false;
strlLog->Add("loggon fail.");
}
else
{
strlLog->Add("Logon ok.");
}
if ( bOk )
{
strlLog->Add("test mailbox.");
RDOMailBoxStore = RDOSession->Stores->DefaultStore;
RDOFolders = RDOMailBoxStore->IPMRootFolder->Folders;
strlLog->Add(AnsiString(RDOFolders->Count) + " folders.");
}
}
}
else
{
bOk = false;
strlLog->Add("error coinitialize");
}
}
catch(Exception &err)
{
strlLog->Add( err.Message );
}
if ( strlLog != NULL )
{
strlLog->SaveToFile("C:\\TEST\\log.txt");
delete strlLog;
strlLog = NULL;
}
if ( RDOFolders != NULL )
{
delete RDOFolders;
RDOFolders = NULL;
}
if ( RDOMailBoxStore != NULL )
{
delete RDOMailBoxStore;
RDOMailBoxStore = NULL;
}
if ( RDOSession != NULL )
{
delete RDOSession;
RDOSession = NULL;
}
Results:
- In a standart application, logged as "Gilles" in our domain (the mailbox
owner), it work :
log :
CoCreateInstance...
LogonExchangeMailbox...
Logon ok.
test mailbox.
23 folders.
-in a service (run as local system) :
CoCreateInstance...
LogonExchangeMailbox...
EAccessViolation
- in a service (run as Gilles)
CoCreateInstance...
LogonExchangeMailbox...
EAccessViolation
indeed, LogonExchangeMailbox does not block, it fail.
maybe a misuse of CoCreateInstance in a service ?
--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"Gilles" <Gil...@discussions.microsoft.com> wrote in message
news:BD5F6634-547D-45D1...@microsoft.com...
Gilles
For detailes see below,
Application Environment:
1. Redumption objects are using in windows service, running under the same account as exchange profile.
2. Outlook is paralley running.
Runtime Environment : Windows XP Professional 2002 Sp3 and Outlook 2007
2009-12-22 16:41:05,325 [2960] INFO RedAlertsOutlookSyncService.RedAlertsOutlookSyncService [] - Logging into Local user profile with empty login name/password..
2009-12-22 16:41:07,184 [2960] INFO RedAlertsOutlookSyncService.RedAlertsOutlookSyncService [] - Current Exchange logged in user name : Code Red
2009-12-22 16:41:07,544 [2960] INFO RedAlertsOutlookSyncService.RedAlertsOutlookSyncService [] - Current Windows user user name : code red
2009-12-22 16:41:07,950 [2960] INFO RedAlertsOutlookSyncService.RedAlertsOutlookSyncService [] - Current user SMTP Address : cod...@chambersenergycapital.com
2009-12-22 16:41:08,497 [2960] INFO RedAlertsOutlookSyncService.RedAlertsOutlookSyncService [] - rdos is Logged in with profile :codered
Runtime Environment : Windows Server 2008 standard and Outlook 2007
2009-12-22 16:45:01,195 [4392] INFO RedAlertsOutlookSyncService.RedAlertsOutlookSyncService [] - Logging into Local user profile with empty login name/password..
2009-12-22 16:45:01,351 [4392] INFO RedAlertsOutlookSyncService.RedAlertsOutlookSyncService [] - Current Exchange logged in user name : UNKNOWN
2009-12-22 16:45:01,788 [4392] INFO RedAlertsOutlookSyncService.RedAlertsOutlookSyncService [] - Current Windows user user name : code red
2009-12-22 16:45:01,788 [4392] INFO RedAlertsOutlookSyncService.RedAlertsOutlookSyncService [] - Current user SMTP Address :
2009-12-22 16:45:01,788 [4392] INFO RedAlertsOutlookSyncService.RedAlertsOutlookSyncService [] - rdos is Logged in with profile :
If you want to look into code see below,
public bool JustLoginAndCheckSharedFolder()
{
Redemption.RDOFolder folder = null, folder1 = null, folder2 = null;
this.rdos = new Redemption.RDOSession();
Helper.logger.Info("Logging into Local user profile with empty login name/password..");
this.rdos.Logon(string.Empty, string.Empty, (object)false, null, null, null);
try
{
if (this.rdos.LoggedOn)
{
Helper.logger.Info("Current Exchange logged in user name : " + rdos.CurrentUser.Name);
Helper.logger.Info("Current Windows user user name : " + rdos.CurrentWindowsUser.Name);
Helper.logger.Info("Current user SMTP Address : " + rdos.CurrentUser.SMTPAddress);
Helper.logger.Info("rdos is Logged in with profile :" + Helper.GetProfileNameFromSMTPAddress(rdos.CurrentUser.SMTPAddress));
}
else
{
Helper.logger.Info("rdos is Failed to login.");
}
return true;
}
catch (Exception ex)
{
Helper.logger.Info("Exception in JustLoginAndGetSharedFolder(),Error : " + ex.Message);
return false;
}
}
public static string GetProfileNameFromSMTPAddress(string eMail)
{
if (!string.IsNullOrEmpty(eMail))
return eMail.Substring(0, eMail.IndexOf("@"));
else
return string.Empty;
}
Any help on this will be greatly appriciated.
Thanks
Madhava
Dmitry Streblechenko wrote:
Re: LogonExchangeMailbox - supressing login dialogs
19-Sep-08
You cannot pass user name/password to the Exchange provider: it always uses
the identity of the current user (parent process) to authenticate with the
server.
Once your are running under the identity of the primary mailbox owner, no
prompts will be displayed. Also note that no prmpts will ever be displayed
when running in a service (Redemption takes care of that).
--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
<hchr...@ulysses-systems.com> wrote in message
news:03b0d4d0-66c0-4e8e...@b1g2000hsg.googlegroups.com...
Previous Posts In This Thread:
On Friday, September 19, 2008 5:25 PM
Dmitry Streblechenko wrote:
Re: LogonExchangeMailbox - supressing login dialogs
You cannot pass user name/password to the Exchange provider: it always uses
the identity of the current user (parent process) to authenticate with the
server.
Once your are running under the identity of the primary mailbox owner, no
prompts will be displayed. Also note that no prmpts will ever be displayed
when running in a service (Redemption takes care of that).
--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
<hchr...@ulysses-systems.com> wrote in message
news:03b0d4d0-66c0-4e8e...@b1g2000hsg.googlegroups.com...
On Saturday, September 20, 2008 5:48 AM
hchristo wrote:
LogonExchangeMailbox - supressing login dialogs
Hello,
Imports Redemption
Imports MSMAPI
Public Class Form1
Try
End Sub
End Class
On Monday, September 22, 2008 12:40 PM
Dmitry Streblechenko wrote:
You need to run your service (Log On tab of the service properties) as the
You need to run your service (Log On tab of the service properties) as the
user whio has access to teh mailboxes in question, call LogonExchangeMailbox
for that user. You can then open other mailboxes using
RDOSession.Stores.GetSharedMailbox.
--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
<hchr...@ulysses-systems.com> wrote in message
news:e429aed7-be77-43b2...@26g2000hsk.googlegroups.com...
On Thursday, September 25, 2008 2:56 AM
hchristo wrote:
Hi Dmitry,Thanks for the quick reply (and appologies for the mutliple posts).
Hi Dmitry,
Thanks for the quick reply (and appologies for the mutliple posts).
Are you saying that it is not possible to have a service connecting to
an exchange server to scan the inbox of anybody other than the
currently logged in user? Even in the case where we have the target
users login and password at hand?
I was hoping that it would be possible to have a service sitting on
the server scanning mulitple users e-mails.
thanks
Harry
On Thursday, September 25, 2008 2:56 AM
cainrando wrote:
Re: LogonExchangeMailbox - supressing login dialogs
You'll want to have the credentials of a "master user" who has
permissions to read all the users' mail that needs to be processed.
On Thursday, September 25, 2008 2:56 AM
hchristo wrote:
Re: LogonExchangeMailbox - supressing login dialogs
ok i'll give that a try...
thankyou for the help :)
On Tuesday, December 02, 2008 5:14 AM
Hannes de Jage wrote:
Does this work remotely.
Does this work remotely. I get a "Could not open the GAL container" error
when calling GetSharedMailbox.
"Dmitry Streblechenko" wrote:
On Tuesday, December 02, 2008 10:27 AM
Dmitry Streblechenko wrote:
What do you mean by "remotelyThat looks just fine.
What do you mean by "remotelyThat looks just fine. Can you try to access it
GAL using Session.AddressBook.AddressLists("Global Address List") *before*
GetSharedMailbox fails?
--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"Hannes de Jager" <Hannes de Ja...@discussions.microsoft.com> wrote in
message news:80ECCB59-CB7C-44A0...@microsoft.com...
On Tuesday, December 02, 2008 10:54 AM
HannesdeJage wrote:
Hi Dmitry, thanks for the reply.I can access the GAL using Session.AddressBook.
Hi Dmitry, thanks for the reply.
I can access the GAL using Session.AddressBook.AddressLists("Global Address
List") like you suggested.
By remotely I meant from a different machine than my exchange server.
I'm running Exchange 2007.
"Dmitry Streblechenko" wrote:
On Tuesday, December 02, 2008 11:04 AM
HannesdeJage wrote:
Re: LogonExchangeMailbox - supressing login dialogs
ps: Below is the code I'm using
session = new RDOSession();
session.logonExchangeMailbox("Admini...@attix5vm.com",
"HDJ-VM-EXCG07");
System.out.println("GAL Item Count: " +
session.getAddressBook().addressLists(new Variant("Global Address
List")).getCount());
System.out.println("Logged On?: " + session.getLoggedOn());
session.getStores().getSharedMailbox(new
Variant("Administrator")).getIPMRootFolder();
From which I get the following output:
GAL Item Count: 0
Logged On?: true
Exception in thread "main" com.jacob.com.ComFailException: Invoke of:
GetSharedMailbox
Source: Redemption.RDOStores
Description: Could not open the GAL container
"Dmitry Streblechenko" wrote:
On Tuesday, December 02, 2008 11:35 AM
Dmitry Streblechenko wrote:
When and how does your code run?
When and how does your code run? Is it running under the
Admini...@attix5vm.com domain user?
--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"Hannes de Jager" <Hannes...@discussions.microsoft.com> wrote in message
news:C154580A-93E3-484A...@microsoft.com...
On Wednesday, December 03, 2008 8:52 AM
HannesdeJage wrote:
I run the code from my Java IDE from a machine that is not part of the domain.
I run the code from my Java IDE from a machine that is not part of the domain.
On Wednesday, December 03, 2008 12:15 PM
Dmitry Streblechenko wrote:
Your code must run under the identity of the domain user who owns the mailbox.
Your code must run under the identity of the domain user who owns the
mailbox.
There is no way around that.
--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"Hannes de Jager" <Hannes...@discussions.microsoft.com> wrote in message
news:A3006970-7397-49E0...@microsoft.com...
On Thursday, December 04, 2008 3:27 AM
HannesdeJage wrote:
Ok, then I have to settle for that. Thank you for your time!
Ok, then I have to settle for that. Thank you for your time!
"Dmitry Streblechenko" wrote:
On Wednesday, January 28, 2009 4:43 AM
Gille wrote:
Hello, I have a problem with LogonExchangeMailbox in a service.
Hello,
I have a problem with LogonExchangeMailbox in a service.
This c++ code works with no prompts (runned under the box owner) in a
standart application:
CoInitialize(NULL);
hr = CoCreateInstance ( CLSID_RDOSession,
NULL,
CLSCTX_INPROC_SERVER,
IID_IRDOSession,
(void**) &RDOSession );
RDOSession->LogonExchangeMailbox( WideString( strUSer ),
WideString( strServerName ));
//...
but in a service (runned as the same user), it seems to block on
LogonExchangeMailbox.
I don't know where is the problem.
an idea ?
"Dmitry Streblechenko" wrote:
On Wednesday, January 28, 2009 11:57 AM
Dmitry Streblechenko wrote:
Are you sure it blocks rather than raises an error that you do not handle?
Are you sure it blocks rather than raises an error that you do not handle?
Is your service running under the identity of the domain Windows user who
wons the mailbox specified in the call to LogonExchangeMailbox?
--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"Gilles" <Gil...@discussions.microsoft.com> wrote in message
news:1A7C460D-866A-4FEE...@microsoft.com...
On Wednesday, January 28, 2009 4:03 PM
Gille wrote:
"Dmitry Streblechenko" wrote:
On Wednesday, January 28, 2009 5:30 PM
Dmitry Streblechenko wrote:
Send an e-mail to my private address - I'll send you a debug version which
Send an e-mail to my private address - I'll send you a debug version which
will log all teh calsl and errors.
--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"Gilles" <Gil...@discussions.microsoft.com> wrote in message
news:BD5F6634-547D-45D1...@microsoft.com...
On Thursday, January 29, 2009 12:48 AM
Gille wrote:
Re: LogonExchangeMailbox - supressing login dialogs
thank you very much,
I just send you a mail.
Gilles
"Dmitry Streblechenko" wrote:
Submitted via EggHeadCafe - Software Developer Portal of Choice
ASP.NET 2.0 Web Application Projects Release Available
http://www.eggheadcafe.com/tutorials/aspnet/fd84bb17-ab18-4f11-9994-d29dd336649d/aspnet-20-web-applicati.aspx
--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
<vaasavi76 Maydipalle> wrote in message
news:200912231623...@codered.com...