Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Email readers and auto responders
Message
From
10/09/2004 14:16:07
 
 
General information
Forum:
Visual FoxPro
Category:
Internet applications
Miscellaneous
Thread ID:
00885122
Message ID:
00941147
Views:
26
>I am looking to auto-respond to some incoming emails; the response will vary according to a keyword in the subject.
>
>Does your "startup program" handle that?
>
>If yes, how do I get a copy?

Here is a startup program that will do some of that:
LOCAL loOutlook,loNS,loInbox,loMailItems,lnCompteur,lnCount,lnCompteur2,lcAddress,llOk
loOutlook=CREATEOBJECT('Outlook.Application')
loNS=loOutlook.GetNameSpace('MAPI')
loInbox=loNS.Folders('Personal Folders').Folders('Spam')
loMailItems=loInbox.Items
CLOSE ALL
USE Email
lnCount=loMailItems.Count
lnCompteur2=0
FOR lnCompteur=lnCount TO 1 STEP -1
   lnCompteur2=lnCompteur2+1
   WAIT WINDOW ALLTRIM(STR(lnCompteur2))+' of '+ALLTRIM(STR(lnCount)) NOWAIT
   loItem=loMailItems.Item(lnCompteur)
   APPEND BLANK
   REPLACE AddDate WITH loItem.CreationTime
   REPLACE Sender WITH loItem.SenderName
   REPLACE Subject WITH loItem.Subject
   IF LEN(ALLTRIM(loItem.Body))>0
      REPLACE Notes WITH loItem.Body
      ELSE
      REPLACE Notes WITH loItem.HTMLBody
   ENDIF
   REPLACE To WITH loItem.To

   * Sender email
   lcAddress=''
   IF '@'$Sender
      lcAddress=Sender
      ELSE
      loReply=loItem.Reply()
      llOk=.F.

      * First, lets try to get it from this method
      IF TYPE('loReply.Recipients.Item(1)')='O'
         IF '@'$loReply.Recipients.Item(1).Address
            lcAddress=loReply.Recipients.Item(1).Address
            llOk=.T.
         ENDIF
      ENDIF

      * If the first method failed
      IF NOT llOk
         IF TYPE('loReply.Recipients[1]')='O'
            loRecipient=loReply.Recipients[1]
            IF NOT EMPTY(loRecipient.Address)
               IF '@'$loRecipient.Address
                  lcAddress=loRecipient.Address
                  ELSE
                  IF '@'$loRecipient.Name
                     lcAddress=loRecipient.Name
                  ENDIF
               ENDIF
               ELSE
               IF '@'$loRecipient.Name
                  lcAddress=loRecipient.Name
               ENDIF
            ENDIF
         ENDIF
      ENDIF

   ENDIF

   REPLACE Address WITH LOWER(lcAddress)

   IF TYPE('loItem.Recipients.Item(1)')='O'
      REPLACE ToAddress WITH LOWER(loItem.Recipients.Item(1).Address)
   ENDIF
   REPLACE NoMember WITH 1
NEXT
WAIT CLEAR
BROWSE
SELECT TTOD(AddDate) AS AddDate,COUNT(*) AS Compte FROM Email GROUP BY 1 ORDER BY 1 DESC INTO CURSOR Temp
BROWSE
CLOSE ALL
The program uses a DBF which gathers the data. It assumes a folder in Outlook named Spam that I was using to gather some stats about the incoming spams we were receiving. However, you can simply use the Inbox as the folder.
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform