Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 293
  • Last Modified:

Assign specific email account to retrieve mail using POP3 Indy Component

I am trying to retrieve mail for a specific email address.  I can connect to the mail server fine, but how or where do I assign which mailbox I want to search?  

POP.Host := 'myHost.com';
POP.Port := 110;
POP.Username := 'TestEmail';
POP.Password := 'test';
  try
    POP.Connect;
  except
    on E : Exception do
      begin
        ShowMessage('Error: '+ E.Message);
      end;
  end;
0
jennifere
Asked:
jennifere
  • 2
1 Solution
 
alunaCommented:
Hi
I don't understand what you want to do, 'cause the component provides direct access to the mailbox for the username and password combination you're using. You have not to assign any other property. After connect, you could use the CheckMessages method to obtain the number of messages in the mailbox and the methods RetrieveHeader or Retrieve to get the message headers only or complete messages.

POP.Host := 'myHost.com';
POP.Port := 110;
POP.Username := 'TestEmail';
POP.Password := 'test';
  try
    POP.Connect;
    num := POP.CheckMessages;
    for i := 0 to num - 1 do
      begin
        POP.Retrieve(i, msg);
        // then you have in msg (of type TIdMessage) all message's properties, such as Subject,
        // Sender, From, etc...
      end;

  except
    on E : Exception do
      begin
        ShowMessage('Error: '+ E.Message);
      end;
  end;
0
 
jennifereAuthor Commented:
Right, I thought using the username and password would give me direct access to my mailbox, however, when I check the mailbox size or call CheckMessages, I am returned a 0.  That's why I thought I might need to assign my mailbox somewhere else. There are messages in this mailbox, I just can not get them.
0
 
alunaCommented:
Do you read your inbox with another POP3 client? If so, check for account config settings like secure password authentication, ssl ports, or any other. Maybe when you connect to the server thare's some special config to let you access the mailbox.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now