Solved

I want to read email using delphi then send en email.

Posted on 2010-09-12
5
1,786 Views
Last Modified: 2013-11-30
Hi,

I am after some info to see if this has been done before but would like to create my own as I only need a very basic version.
I need to read emails from my hotmail account and only emails with a certain header.
For example all emails that say: Item no.20054342 - Notification of an Instant Payment Received from
Then only show that header in my delphi program in real time.
I then want to pre-type x250 serial numbers around 25 letters long.
Each time a new email arrives in my program a new serial number is sent to the new email, once a serial number has been sent it should be removed
and stored along with that email header with its own ref number which is the 25 letter serial number.
I should be able to change the header to look for as my item number will change every week.


where do I start and whats the best way to tackle this, I want to make sure my customers get there code faster than what I can do manually.
must be coded in delphi
0
Comment
Question by:Emailcoder1
  • 3
5 Comments
 
LVL 5

Expert Comment

by:Mechanic_Kharkov
ID: 33657283
You can deal with installed email client via MAPI interface to read messages and create them in this client's Inbox and Outbox. In some cases it's the best way. But it's not a very reliable solution (bugs in MAPI, poor documentation).

And You can use Indy components to handle SMTP and POP3 clients functionality directly in Your application. These components are called TIdPOP3, TIdSMTP, or even TIdIMAP4.
It's more reliable way to deal with mail. Samples of using these components are in the web. Just google for them.
0
 

Author Comment

by:Emailcoder1
ID: 33657307
Thanks, im using delphi 7 so i have a good selection of indy components. Can someone provide a working exmaple.

of a memo1 to use these components that as soon as the form is loaded, it imports all my inbox into memo1. Only messages starting with "item 220"

?
0
 
LVL 32

Accepted Solution

by:
ewangoya earned 500 total points
ID: 33657366
procedure TForm1.Button2Click(Sender: TObject);
var
  I, MsgCount: Integer;
  EMessage: TIdMessage;
begin
  if IdPOP31.Connected then
    IdPOP31.Disconnect;

  IdPOP31.Host := 'POP3 Host';
  IdPOP31.Port := Port No;
  IdPOP31.Username := 'UserName@email.com';
  IdPOP31.Password := 'Password';
  IdPOP31.Connect;
  MsgCount := IdPOP31.CheckMessages;

  for I := 1 to MsgCount do
  begin
    EMessage.Clear;
    IdPOP31.Retrieve(I, EMessage);
    //Do something with your email
    //IdPOP31.Delete(I); //delete if you don't need it anymore
  end;
  IdPOP31.Disconnect; //It will delete the mail which was marked for deletion
end;
0
 
LVL 5

Expert Comment

by:Mechanic_Kharkov
ID: 33657369
Collection of Indy demos "from first hands"
http://www.indyproject.org/Sockets/Demos/index.EN.aspx

I have D7 too. In my one there is Indy ver 9.00.10 included.
So, download this file:
http://www.projectindy.org/DemoDownloads/Indy9Demos_26Oct04.zip

and use included project from folder "Indy9Demos\MailClient".

It's easy to understand because Indy in a whole use blocking mode of socket operations. Just try it!

0
 
LVL 5

Expert Comment

by:Mechanic_Kharkov
ID: 33657390
> it imports all my inbox into memo1. Only messages starting with "item 220"

The POP3 protocol does not allow to read message header without reading entire message. It's a limitation of the protocol. So, You need to download entire message to detect that it's subject begins with 'item 220'. If it's critical to filter messages before downloading, You should use IMAP4 vs POP3. IMAP4 can read messages, and download them partially. But I has no idea whether Hotmail supports IMAP4 or not. Do not forget to heck thos condition before consider to use IMAP4.
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you can connect to your internal network or can connect to your router but are not able to connect to the Internet follow these steps in order until the problem is resolved.   1. Right click on the network icon on the task bar and select "Troub…
Zimbra is famous for its platform independency, ability to manage multiple user accounts, easy assimilation with 3rd party applications, social network certification etc. Here, we discuss about how users can move multiple Zimbra user accounts to Exc…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
In this Experts Exchange video Micro Tutorial, I'm going to show how small business owners who use Google Apps can save money by setting up what is called a catch-all email address in their Gmail accounts. By using the catch-all feature, small busin…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question