Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Authentic with Indy's IMAP4 component

Status
Not open for further replies.

Griffyn

Programmer
Jul 11, 2002
1,077
AU
Hi all,

I'm trying to access a public folder on an Exchange 5.5 server. Public Folder's don't allow POP3 access, even though that's all I need, but they do support IMAP4 (
I'm trying to use Indy's IMAP4 component. In my test prog, I've set Host to my Exchange's server name (or IP address), Username to my <domain>\<username> and set the Password property. All other properties as default, but I've played around a fair bit with them, including the SSL options.

TIdIMAP4.Connect works ok which also should Login, but the ConnectionState property is set to csNonAuthenticated, which is not sufficient to then Select a mailbox and read headers, etc.

Has anyone worked with IMAP and Exchange before? Perhaps an IMAP component from Jedi (couldn't see one, although they do have a MAPI component; from the weblink above it would appear this should work too) would work where this doesn't.

The error message I get when using the TIdIMAP4.SelectMailbox is the same (Wrong Connection State, [ConnectionState is NonAuthenticated]) regardless of the username or password I'm using.

So the Login is failing, but I can't tell why.

Code:
[navy][i]// for automatic syntax highlighting see faq102-6487 
[/i][/navy][b]procedure[/b] TMainForm.Button1Click(Sender: TObject);
[b]begin[/b]
  [b]if[/b] IMAP4.Connected [b]then[/b]
  [b]begin[/b]
    Button1.Caption := [teal]'Connect'[/teal];
    IMAP4.Disconnect;
  [b]end[/b]
  [b]else[/b]
  [b]begin[/b]
    Memo1.Clear;
    [b]if[/b] IMAP4.Connect [b]then[/b]
      Button1.Caption := [teal]'Disconnect'[/teal];
  [b]end[/b];
[b]end[/b];

[b]procedure[/b] TMainForm.IMAP4Status(ASender: TObject; [b]const[/b] AStatus: TIdStatus;
  [b]const[/b] AStatusText: String);
[b]begin[/b]
  Memo1.Lines.Add(AStatusText);
[b]end[/b];

[b]procedure[/b] TMainForm.IMAP4Connected(Sender: TObject);
[b]begin[/b]
  [navy][i]// next line causes an exception
[/i][/navy]  IMap4.SelectMailBox([teal]'Spam Catcher'[/teal]);
[b]end[/b];

I've played around with the TIdIMAP4.Capability method and got it to return the following strings from my Exchange server:

IMAP4
IMAP4rev1
IDLE
LITERAL+
LOGIN-REFERRALS
MAILBOX-REFERRALS
NAMESPACE
AUTH=NTLM

The last entry worries me a little, perhaps Indy's IMAP4 client doesn't support the authentication method required by Exchange 5.5?

Any help would be much appreciated!
 
Worked it out. Combination of things.

First, the TIdIMAP4.OnConnected event is called prior to Login, therefore any code in there cannot run with authentication.

Second, the TIdIMAP4.Username property should not include the domain name.

I'm authenticated! hooray!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top