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!

Outlook Express - Saving message information

Status
Not open for further replies.

jmcd0719

Programmer
Jun 13, 2001
37
US
We receive emails from our website each day from potential customers. The email is sent to our mailbox with 10 questions answered (Last name, first name, address, etc).

The format is exactly the same, it comes from the same email address with the same subject each time.

What I want to do is save the body of the message as a text file so I can import into tables.

Thanks in advance.
 
jmcd0719,

If you're using Outlook Express, you're pretty well out of luck. As far as I know, there is no easy way to access OE programmatically.

For this sort of work, life is much easier if you use the full Outlook.

Mike


Mike Lewis
Edinburgh, Scotland

My Visual Foxpro web site: My Crystal Reports web site:
 

The only solution I know exists is the following link, unfortunatly it requires a membership access . This function will retrieve you e-mail messages that are in your inbox from your default e-mail program, so if Outlook Express is your default e-mail program, it will retrieve the messages, including the body of the e-mail.

This code retrieves messages from your mailbox (Inbox) and stores them in a cursor.


Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Here's some pure VFP code (using the mswinsock control) that can retrieve specific messages from any POP3 account.

It's best if all emails that you are wanting are going to an email account which is not checked by any other email program (like Outlook Express). You could run the VFP program before retrieving mail with OE, but there's a small chance of a couple emails being received just after the VFP, and just before OE, thereby being missed.

Most Web hosts allow you to create enough email boxes that it isn't a problem to dedicate one just for programmatic retrieval.
 
Thanks Mike, Mgagnon and Wgcs for your prompt response. I am fairly sure these will be usable. If the client upgraded up to full Outlook, is there another solution?

Thanks in advance.

 
Check out the Outlook automation FAQs in forum184

Brian
 
jmcd0719 ,

If the client upgraded up to full Outlook, is there another solution?

Yes, this can easily be done via Automation. There are pleny of code samples kicking around on Tek Tips and elsewhere.

Mike



Mike Lewis
Edinburgh, Scotland

My Visual Foxpro web site: My Crystal Reports web site:
 
Hello.

>> We receive emails from our website each day from potential customers. The email is sent to our mailbox with 10 questions answered (Last name, first name, address, etc).

The format is exactly the same, it comes from the same email address with the same subject each time.

What I want to do is save the body of the message as a text file so I can import into tables. <<

You can do this using MAPI. However, because of the Draconian Security Patch from H*ll, you will also need to use something like Express Click Yes ( ) to suppress the messagebox that pops up to warn you that something is trying to access your inbox. The program is free and it comes with VFP sample code.

You can create a mapi class using a container and dropping 2 ActiveX container controls into it. One will hold the mapi messages control (called oMessage) and the other will hold the mapi session control (called oSession). You can then use sample code like this to get started:

First you need to create a MAPI session:

Code:
LPARAMETERS tcUserName, tcPassword
WITH THIS.oSession
  *** Save the current directory because the following code will change it
  lcCurDir = FULLPATH( CURDIR() )
  *** Go ahead and set the properties and sign on
  .UserName = tcUserName
  .Password = tcPassword
  .DownloadMail = .T.
  *** And sign on
  .SignOn()
ENDWITH
*** Change back to default directory
SET DEFAULT TO ( lcCurDir )

Next, you need to read the messages. Code like this:
Code:
lcSender = 'someone@somedomain.com'
lcSubject = 'something i am interested in'
WITH THIS.oMessage
  .SessionID = This.oSession.SessionID	
  .FetchUnreadOnly = .T.
  .Fetch()
  FOR lnMsg = 1 TO .MsgCount
    *** The Message Index is 0-based, so adjust
    .MsgIndex = lnMsg - 1
    IF ( lcSender $ LOWER( .MsgOrigDisplayName ) OR lcSender $ LOWER( .MsgOrigAddress ) ) AND ( lcSubject == ALLTRIM( LOWER( .MsgSubject ) ) )
      *** Process the body of the message here
      lcText = .MsgNoteText
      *** Now use STRTOFILE to save the message as
      *** a text file or just insert it into a memo
      *** field in a table or whatever processing you 
      *** need to do       
    ENDIF
  ENDFOR
ENDWITH


Marcia G. Akins
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top