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

How to check email using VFP

Status
Not open for further replies.

melchorsy

Programmer
Jul 31, 2002
4
PH
*when i send email i use the following code as i
*got it from one of the threads below:

oSmtp = CREATEOBJECT("SMTPControl.SMTP")
oSmtp.SERVER="192.168.1.1"
oSmtp.Port=25
oSmtp.MailFrom="joesomeone@somewhere.net"
oSmtp.SendTo="suesomeone@somewhere.net"
oSmtp.MessageSubject="Spreadsheet"
oSmtp.MessageText="Here is your spreadsheet."
oSmtp.Attachments.Add("c:\Spreadsheet.xls")
oSmtp.SendEmail

*this works fine!
*Now what about checking email and retrieving email
*from the server?
 
Your .OCX conrol is for sending email only. Now, are you trying to make VFP as an email client?

Peping
 
melchorsy

There is a way to check for unread messages and retreiving them in a table. But it requires automating Outlook and I think you mentionned you want to avoid that. Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first
 
yes peping, i want to build a simple program that would act as a simple client.

as to mgagnon, if there is no other choice, then how are we going to automate Outlook?
 
melchorsy

as to mgagnon, if there is no other choice, then how are we going to automate Outlook?

This will create a cursor of unread messages in your inbox.

Code:
oO=CREATEOBJECT("outlook.application")
ns=oO.GetNamespace("MAPI")
df=ns.GetDefaultFolder(6)
loItems=df.Items
CREATE CURSOR unReadEmails (subject c(40),body c(100))
FOR EACH loItem IN loItems
   IF loItem.unread
     INSERT INTO unReadEmails (subject,body) VALUES (loItem.subject,loItem.body)
   ** You could mark them as read here
    ENDIF
NEXT
BROWSE

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first
 
There are many other ways of doing this, too. There are many OCX controls out there that offer SMTP sending, and POP3 retrieval of email (see for one example... it's $345.00, but it's worth it.. I use this for a POP3 client).

If you end up automating Outlook for sending and retrieving email to create a simple mail client, then what's the point of making a mail client, since the user is required to have and use Outlook (since outlook must be properly configured for you to send/recv email through it)?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top