Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
TELNET and communictation objects
Message
From
05/06/2001 19:24:58
 
 
To
04/06/2001 23:05:33
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
00512453
Message ID:
00515492
Views:
14
>>>I am trying to open a private TELNET session through VFP6SP4 to our private pop3 server. The goal is to try and have 'basic' msgs picked up from the pop3 server, without the overhead of a standard Outlook msg.
>>>Could someone please help me with the right COM object I should be using, and hopefully help point to a place where I can find some documentation??
>>
>>Why not just use the Mabry MAILX control (www.mabry.com)? I use it all the time - small footprint, fast, very reliable. They also have a TELNET control you could use if you really wanted to do it through TELNET.
>>
>>Best of luck,
>>
>>-Arne
>
>Arne,
>
>I don't suppose you have any examples of using this mail/x in the vfp environment.. I am a bit confused (we don't use VB - the source code) on calling the object mailing to smtp and reading from a pop3....
>

Ric,

yeah, it took a while for me to figure it all out. I even decided to review the RFC for POP3 and for SMTP!

The simplified example below is for retrieving mail from a POP3 server. Basically, put the Mail control on a form. Let's call it MMAIL1. In this example - which is simpler than async - I have set MMAIL1.Blocking = .T. The doc should explain this.

The other form properties I use should be obvious from the code below.

Create a method called GETNEXT with the following code:

ThisForm.MMAIL1.MessageID = STR(VAL(ThisForm.MMAIL1.MessageID) + 1)

*Flags 132 = 4 (SrcIsHost) + 128 (DstIsBody)
ThisForm.MMAIL1.Flags = 132

ThisForm.MMAIL1.tag = "next"
ThisForm.txtHeaders = ""
ThisForm.txtBody = ""
ThisForm.txtFrom = ""
ThisForm.txtSubject = ""
ThisForm.lblStatus.Value = "Retrieving Order ";
+ ALLTRIM(ThisForm.MMAIL1.MessageID) + " of ";
+ ALLTRIM(STR(thisform.MMAIL1.PopMessageCount))
ThisForm.MMAIL1.ReadMessage



Then, I have a CONNECT button that contains in the CLICK method:

This.Enabled = .F. &&Disable the button
Thisform.MMAIL1.Host = ALLTRIM(ThisForm.txtHost.Text)
Thisform.MMAIL1.LogonName = ALLTRIM(ThisForm.txtLogonName)
Thisform.MMAIL1.LogonPassword = ALLTRIM(ThisForm.txtLogonPassword)

*Depending on what you are connecting to, you may need to change
* ConnectType below:
Thisform.MMAIL1.ConnectType = 1

* Flag 4 = MailSrcIsHost
ThisForm.MMAIL1.Flags = 4

ThisForm.MMAIL1.Tag = "connect"
ThisForm.MMAIL1.Connect
ThisForm.lblStatus.Value = "Connecting..." &&Let the user know wassup

IF ThisForm.MMAIL1.PopMessageCount < 1 THEN
MESSAGEBOX("No EMail Waiting.", 0, "No EMail to Retrieve")
ThisForm.MMAIL1.Tag = "disconnect"
ThisForm.lblStatus.Value = "Disconnecting..."
ThisForm.MMAIL1.Disconnect
ThisForm.Release
ELSE
ThisForm.MMAIL1.MessageID = 0
ThisForm.MMAIL1.Tag = ""
ThisForm.lblStatus.Value = "You have ";
+ALLTRIM(STR(ThisForm.MMAIL1.PopMessageCount));
+" emails to retrieve."
ThisForm.cmdConnect.Enabled = .F.
ENDIF

ThisForm.Process.Enabled = .T. &&Allow them to click the PROCESS
** (or RETRIEVE if you like) button


Then I have a PROCESS button (that actually retrieves the mail) where the CLICK method is:

This.Enabled = .F.
ThisForm.Exit.Enabled = .F.
ThisForm.cmdConnect.Enabled = .F.

DO WHILE VAL(ThisForm.MMAIL1.MessageID) + 1 <= ThisForm.MMAIL1.PopMessageCount
ThisForm.GetNext

ThisForm.txtFrom = ThisForm.MMAIL1.From
ThisForm.txtSubject = ThisForm.MMAIL1.Subject
ThisForm.txtHeaders = ThisForm.MMAIL1.HeaderText


*YOU MAY HAVE TO Handle multi-part msgs here...
IF ThisForm.MMAIL1.Parts > 0

*get the other parts and add them to ThisForm.txtBody
* use the MMAIL1.DESCEND method...

ELSE
ThisForm.txtBody = ThisForm.MMAIL1.Body(0)
ThisForm.MMAIL1.Tag = ""
ENDIF

* DO WHATEVER YOU WANT WITH THE MAIL; ThisForm.txtBody contains
* the message text. The other form properties filled in GetNext
* contain subject, from , etc.

*Delete the Message from the HOST; remove this
* to 'leave mail on server'
ThisForm.HostDelete
ENDDO

=MESSAGEBOX("All Current Messages Retrieved. Click OK to Exit.",16,"Processing Completed")

ThisForm.MMAIL1.tag = "disconnect"
ThisForm.lblStatus.Value = "Disconnecting..."
ThisForm.MMAIL1.Disconnect

ThisForm.release

That's pretty much it. You might find little issues with the BLOCKING and the SERVERTYPE but play with this code and you'll get it to work. Might want to remove firing the HostDelete while testing :)

If you need help with outgoing (SMTP) post and I'll show you a working example of that too. Biggest problem there is typically which ServerType to use (SMTP or ESMTP).

If you need more help, let me know. Good luck,

-Arne
arne@synercom-edi.com "There are no absolutes but this one."
President, synercom/edi - Event Ticketing Solutions
Previous
Reply
Map
View

Click here to load this message in the networking platform