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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How best to check email from VFP6 without using Outlook? 2

Status
Not open for further replies.

KarenLloyd

Programmer
Nov 23, 2005
138
GB
Hi there Gurus,

Please can I seek your advice on yet another challenge?

I need to monitor a web mail address from VFP6 without using Outlook automation. The email account has IMAP and POP3 settings, may be accessed using SSL or non-SSL and will be used for one purpose only, to receive notifications from a third-party app.

The checking process may be called on one or two computers where the users have Outlook open constantly for their own business mail.

I want to connect to the email address, check for new messages and pick up the subject header from each. The messages can be deleted as they are processed. I don't really need to read the body of the email or process any attachments at this stage.

I have been reading articles about Winsock, CDO, MAPI and Simple MAPI - but I'm not sure which one will do what I need.

Could anyone please point me in the right direction?

Thank you.
Karen
 
I made a test form once for exactly the same scenario as yours just using winsock. As long as you can use POP and non-SSL, it's not that much work.
You can just open the port, send credentials, then send other commands as you need to.


-Dave Summers-
[cheers]
Even more Fox stuff at:
 
Thanks, Dave

Then that's what I will try first.

Cheers

Karen
 
One question:

If the users retrieve mail, is it still kept server side? As you talk of IMAP, that would speak for a mail repository kept online and synced with mail clients. POP mailretrieval also does not by itself mean deletion of retrieved mails, but is typically configured that way.

So when you check for certain mail subjects, but users have retrieved mails in outlook already, and deleted them on the mail server, you will not catch them.

I suggest there is a special mail address needed for the notifications you look out for. That way there also is no cluttering of normal business mail with such notifications.

Bye, Olaf.

 
Hi Olaf

The email account will be separate from the company email and will never be accessed with Outlook. It will only be used for receiving notifications from a third-party app to say that a form has been submitted to their app.

I want to pick up each new email that comes into this account, read the form ID from the subject heading into a database and then delete the message.

I will then use the ID to collect form data from the 3rd party app.

Thanks

Karen
 
That sounds sound in itself.

But if you receive eg an order form by mail, you'd have other means of processing html form input by a webserver script.
Nevermind, though, I'll not be responsible for turning your concept upside down.

Bye, Olaf.
 
Hi again

Where can I find the winsock vcx, please? It isn't installed with my VFP6. Is there a version in the system folders - in a DLL perhaps - or is it something I can download?

Thanks

Karen
 
winsock is a system component: winsock.ocx, so you'll find it under activeX, it's not a foxpro class, neither base nor any download you're missing.

Nigel is right in that Chillkat components are somewhat esier to use. Still winsock is mainly a class to send and receive TCP/IP or UDP packets of data. Winsock is the basis of speaking to a network, no matter if LAN or Internet. It's even lower level than http requests, eg you could implement the http protocol on the basis of winsock.

So it's not at all a high level componente having easy to use POP3 server login/authenticate, request list of mail subjects, etc.

Here I found some code for accessing a mail server:

Bye, Olaf.
 
As Olaf said, you should be able to find it in your windows directory somewhere, as it gets installed with VB. If for some reason you don't find it, feel free to download the TELNET client demo I have on my site. It has winsock.ocx included.
Follow the link in my signature, then scroll down until you see the "VFP Telnet Client" .zip file.


-Dave Summers-
[cheers]
Even more Fox stuff at:
 
Code:
PROCEDURE INIT
 THIS.OCXSOCKET = CREATE('mswinsock.winsock')

This creates a winsock object (instance) in the fox wiki code I referred to. So simply try o = createobject('mswinsock.winsock') in the command window and you'll see, if you already have winsock installed with VFP or the OS. I guess you don't even need the Telnet download Dave offers.

Bye, Olaf.
 
Another thing about the availability: redist.txt refers to MSWINSCK.MSM, so we are allowed to redistribute a winsock installer, and it's very likely this also means a VFP installation itself installs winsock.ocx, as the same goes for eg the ms calendar activex and other ocxes.

Bye, Olaf.
 
HI - Thank you for your additional input on this thread, Nigel, Dave and Olaf.

I downloaded and registered winsock and then spent a few hours trying to work around "Class is not licensed for use" and the "Object class is invalid for this container". Then found I couldn't get any further as the object connect statement would always fail.

I found an old program I had used for MAPI email pre 1999, but I can't get a successful mapi session for some reason.

Then I found this - - Winsock: reading email messages (POP3, port 110), but I now need to figure out how to extract the subject headings as the results seem to be encoded.

Using MAPI would make things so much simpler, as would just using Outlook. Time for a rethink, me thinks...

Kind regards

Karen
 
>Class is not licensed for use
See here: [URL unfurl="true"]http://www.berezniker.com/content/pages/visual-foxpro/read-pop3-mail-using-winsock[/url]
Sergey explains the license issue -why createobject("mswinsock.winsock") only works on PCs with VFP installed.

In more detail about the license issue: [URL unfurl="true"]http://www.berezniker.com/content/pages/visual-foxpro/appropriate-license-class-not-found-error-runtime[/url]

As far as I remember you even have to put the winsock activex control on a form to make it work compiled as EXE, to create e vcx class may not be enough. Things might also differ for VFP6,7,8, and 9.

Bye, Olaf.
 
Hi. Thanks, Olaf

That link points to one of the pages that I have used for reference. I tried both the subclass and form methods but had an unknown object type error on the connect part...

Anyway, I might be able to put Outlook on a form - I'll try that next to see whether it affects the login of the Outlook app outside of VFP - if not, then that's my solution. I'm fine with automation, just not so fine with learning new tricks when up against tight deadlines.

Best wishes

Karen
 
>but had an unknown object type error on the connect part...

Well, if the winsock is subclassed, all references have to change to address the winsock INSIDE the olecontrol "container". And the same of course goes for a form as basis of a winsock class, you have an additional container around the winsock object in both cases, so all code addressing it needs to be adjusted, too. That's no new trick.

Well, outlook automation of course is easy enough, you don't need to show outlook at all to automate it. So you don't even need to put it on a form, why would you do that?

If your application is started by a windows account having that extra mail account as it's own standard mail address you don't even need to login, you'd be able to set it as the outlook default.

You do
Code:
oOutlook = CREATEOBJECT("outlook.application")
oOutlook.Session.SendAndReceive(.f.)

and then continue examining the inbox folder for new mail items. That's much simpler code than using winsock to connect to a pop3 server and retrieve a mail list, isn't it?

Bye, Olaf.
 
Hi Olaf

I really must stop over-complicating things and trying the hard route first.

I have decided to use Outlook after all, just to simplify and move this forward.

I can set up rules in Oulook to filter certain messages into a sub-folder of the Inbox, where they can be processed from VFP.

This also means that I will eventually be able redirect emails according to form type onto the appropriate member of the team. (Why didn't I think of this before?) I'll have to deal with holiday notices and out of office replies etc - but it seems a good idea to me so far.

Finally - I think I have found my way back out of the woods.

Thank you once again for your help.

Kind regards

Karen
 
Sending mails to a certain folder by an outlook rule is indeed a good idea. You also have to mark processed mails somehow, or delete them.

I recommend one download, just for the code: OLIndex.zip from [URL unfurl="true"]http://www.foxpert.com/downloads.htm[/url]

This will show you how to deal with mail items in pretty much any aspect ou could ask. It's a bit outdated, but would still work, perhaps even with VFP6. You don't need to go as far as indexing mail texts, but you'll find reference code, eg using the unique EntryID to reidentify mails, or using the Unread property to flag mails as read = processed. It sure is more helpful than reading MSDN reference about the outlook object model with sparse samples.

Bye, Olaf.
 
Hi

I have already laid down the basics for what I need - but this download looks interesting and could well be useful as the number of emails increases.

I came across this earlier, OUTLOOK AUTOMATION PART 3 - which has quite a list of Outlook properties that I hadn't seen before.

Anyway, thank you again Olaf.

Best wishes

Karen
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top