Is it possible to read and send mails from Exchange Server?

Is it possible to read and send mails from Exchange Server?

Postby Horizon » Tue Nov 17, 2009 12:16 pm

Hi,

Is it possible to read and send mails from Exchange Server? Is there any example for it?

Thanks in advance.
Regards,

Hakan ONEMLI

Harbour & MSVC 2022 & FWH 23.04
Horizon
 
Posts: 1322
Joined: Fri May 23, 2008 1:33 pm

Re: Is it possible to read and send mails from Exchange Server?

Postby anserkk » Tue Nov 17, 2009 12:48 pm

Do you mean to say that you would like to Send/Receive email withot using Outlook Express/ MS Outlook or any other email client software

I believe that you can use CDO to access Exchange Server or any mail server to send and receive emails.
http://forums.fivetechsupport.com/viewtopic.php?f=3&t=15843

Regards
Anser
User avatar
anserkk
 
Posts: 1333
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: Is it possible to read and send mails from Exchange Server?

Postby Horizon » Tue Nov 17, 2009 2:44 pm

Thanks Anser,

This example is related sending mails. Is there any examples that reading mails?
Regards,

Hakan ONEMLI

Harbour & MSVC 2022 & FWH 23.04
Horizon
 
Posts: 1322
Joined: Fri May 23, 2008 1:33 pm

Re: Is it possible to read and send mails from Exchange Server?

Postby anserkk » Tue Nov 17, 2009 4:51 pm

Hi Hakan,

Sorry, I don't have any samples to demonstrate retrieval of email messages from a POP3 server. I have not tried this till now.
I think MAPI is the way to go for reading mails and CDO is used mostly for sending mails.

Regards
Anser
User avatar
anserkk
 
Posts: 1333
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: Is it possible to read and send mails from Exchange Server?

Postby anserkk » Wed Nov 18, 2009 8:12 am

Hi all,

Anybody here tried to read a POP3 Server to find out new unread mails in a POP3 server. I understand that MAPI32.DLL is used and the progid for the DLL is
CREATEOBJECT (the ProgIDs for these controls are MSMAPI.MAPIMessages and MSMAPI.MAPISession).

But I am getting an error when I try this
Code: Select all  Expand view  RUN
oSession:=CreateObject("MSMAPI.MAPISession")


I get the following error

[list=]Application
===========
Path and name: D:\FwhExtra\FWHTests\ReadMail.exe (32 bits)
Size: 1,846,784 bytes
Time from start: 0 hours 0 mins 0 secs
Error occurred at: 11/18/09, 13:40:20
Error description: Error TOleAuto/65535 : TOLEAUTO:NEW
Args:
[ 1] = C MSMAPI.MAPISession
[ 2] = U
[ 3] = U

Stack Calls
===========
Called from: => THROW(0)
Called from: source\rtl\win32ole.prg => TOLEAUTO:NEW(346)
Called from: source\rtl\win32ole.prg => CREATEOBJECT(78)
Called from: ReadMail.prg => MAIN(7)
[/list]

Any idea ? Do I have to use the DECLARE DLL ?

Regards
Anser
User avatar
anserkk
 
Posts: 1333
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: Is it possible to read and send mails from Exchange Server?

Postby James Bott » Wed Nov 18, 2009 12:08 pm

Anser,

Have you tried searching the forum for "POP3?" I seem to remember there was some sample code for this.

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Is it possible to read and send mails from Exchange Server?

Postby anserkk » Wed Nov 18, 2009 12:28 pm

Dear Mr.James,

I tried the followinng link in the spanish forum, but unfortunately I could not get it work.
viewtopic.php?f=6&t=6258

As per the link, you need to download an OCX file named MSMAPI32.OCX. But even after registering the OCX, the program crashes. If you check the Valtype of the object created, instead of Object, it is showing as NUMERIC.

I am looking for a solution that works without any additional OCX control. I thought that the default CDO/MAPI would work without installing any additional OCX

Regards
Anser
User avatar
anserkk
 
Posts: 1333
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: Is it possible to read and send mails from Exchange Server?

Postby James Bott » Wed Nov 18, 2009 12:57 pm

Anser,

Search for "TPOP3"

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Is it possible to read and send mails from Exchange Server?

Postby anserkk » Thu Nov 19, 2009 5:02 am

Dear Mr.James,

Thank you. FiveWin's TPop3 is working fine and this the one which I was looking for. Now I need to understand the techniques used to extract the header, attachments, Subject, Sender's details etc. from the array aMsgs

Regards
Anser
User avatar
anserkk
 
Posts: 1333
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: Is it possible to read and send mails from Exchange Server?

Postby James Bott » Thu Nov 19, 2009 6:48 am

Anser, you can find that info here:

viewtopic.php?f=3&t=2069&p=8878&hilit=tpop3#p8878

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Is it possible to read and send mails from Exchange Server?

Postby anserkk » Thu Nov 19, 2009 9:19 am

Dear Mr.James,

Another problem which I see is that TPop3 downloads the whole email. (TelNet command RETR). I have to download the whole mail and then extract the headers from it and will be time consuming if attachments are there ( depends on the email size). Hope there is some other technique to get the header only (From,To,Subject,Email Size), so that it is faster. Nowadays, most mobile phone supports the retrieval of Email Headers. I know that TPop3 is supposed to be used to retrieve emails from POP3 servers. Just wondering whether another method exist to retrieve the header only. I did not find any TelNet commands to retrieve just the header. LIST will give the message no's and size in bytes

Regards
Anser
User avatar
anserkk
 
Posts: 1333
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: Is it possible to read and send mails from Exchange Server?

Postby James Bott » Thu Nov 19, 2009 3:39 pm

Anser,

Just wondering whether another method exist to retrieve the header only.


I know that this is possible because I have a program that does it (not a FW program). I do not know how to do it using FWH. I would try searching the NET.

Regards,
James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Is it possible to read and send mails from Exchange Server?

Postby anserkk » Fri Nov 20, 2009 6:00 am

Dear Mr.James,

With few minor changes in our own FiveWin Class TPop3, we can get the headers only from email. This method is fast, because the whole email is not downloaded, but just the headers. I modified the class with an additional data, so that the programmer can decide whether he wants to download the whole email message or just the header.

Code: Select all  Expand view  RUN
oInMail = TPop3():New( cIp,, cUserName, cPassword )  
oInMail:lHeaderOnly:=.T.  // Retrieves only the headers
 

The default value of the data ::lHeaderOnly is .F., and for those who require to download only the headers can set the value to .T.

This will be useful for those who want to check the email messages for a specific subject/From address in a much faster way.

Regards
Anser
User avatar
anserkk
 
Posts: 1333
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: Is it possible to read and send mails from Exchange Server?

Postby Horizon » Fri Nov 20, 2009 7:40 am

Hi Anser,

Is it possible to share changes in TPop3 Class if you don't mind?

Thanks in advance.
Regards,

Hakan ONEMLI

Harbour & MSVC 2022 & FWH 23.04
Horizon
 
Posts: 1322
Joined: Fri May 23, 2008 1:33 pm

Re: Is it possible to read and send mails from Exchange Server?

Postby anserkk » Fri Nov 20, 2009 7:50 am

The changes required in TPop3.Prg

CLASS TPop3
Code: Select all  Expand view  RUN
DATA   lHeaderOnly   // New Data


METHOD New()

Code: Select all  Expand view  RUN
  ::lHeaderOnly:=.F.  // Initialize the Value to .F.


In METHOD OnRead()

Line 147
Code: Select all  Expand view  RUN
         if ::lHeaderOnly
                    cCommand  = "TOP " + AllTrim( Str( 1, 4, 0 ) )+ " 0" + CRLF
                 Else
                    cCommand  = "RETR " + AllTrim( Str( 1, 4, 0 ) )+ CRLF
                 Endif
 

Line 161
Code: Select all  Expand view  RUN
         if ::lHeaderOnly
                    cCommand  = "TOP " + AllTrim( Str( ++::nAtMsg, 4, 0 ) ) + " 0" + CRLF
                 Else
                    cCommand  = "RETR " + AllTrim( Str( ++::nAtMsg, 4, 0 ) ) + CRLF
                 Endif
 

Line 183
Code: Select all  Expand view  RUN
        if ::lHeaderOnly
            cCommand  = "TOP " + AllTrim( Str( ++::nAtMsg, 4, 0 ) ) + " 0" + CRLF
        else
            cCommand  = "RETR " + AllTrim( Str( ++::nAtMsg, 4, 0 ) ) + CRLF
                 Endif
 

Mr.Antonio,

Do you mind including this modified class in the next FWH build ? I shall send the modified class to your mail id

Regards
Anser
User avatar
anserkk
 
Posts: 1333
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 51 guests