Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Outlook error trapping
Message
De
31/05/2015 13:48:10
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows 8.1
Network:
Windows 2008 Server
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01620408
Message ID:
01620412
Vues:
46
This routine will check whether an email address is legal or not:
Function ValidEmail
Lparameters tcMail
Local lcPattern As String, ;
   llReturn As Boolean, ;
   loRegex As Object
If Pcount() > 0 And Vartype(m.tcMail) = [C]
   Text To m.lcPattern Noshow Pretext 15
      (?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*
   |  "(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]
       |  \\[\x01-\x09\x0b\x0c\x0e-\x7f])*")
 @ (?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?
   |  \[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}
        (?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:
           (?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]
           |  \\[\x01-\x09\x0b\x0c\x0e-\x7f])+)
      \])
   Endtext
   m.lcPattern = Strtran(m.lcPattern, [ ], [])
   m.loRegex = Createobject([VBScript.RegExp])
   m.loRegex.Pattern = m.lcPattern
   m.loRegex.IgnoreCase = .T.
   m.loRegex.Global = .F.
   m.llReturn = m.loRegex.Test(m.tcMail)
   m.loRegex = .Null.
   Release m.loRegex
Endif
Return m.llReturn
>I am using the following simple code to send a batch of emails based
>on a file with records containing an email address (act_email) and a
>file name (mfilename).
>
>My issue is that occasionally the operator entering the email addresses will
>make a mistake and enters a blank as the first digit or two @ signs, etc. This causes
>an error to be generated and the program halts.
>
>Is there a simple way if an error is generated to just skip to the next record? Obviously,
>an On Error with a retry will not work, but I'm sure an On Error function of some sort is
>the key to the solution. Something as simple as the On Error forcing the code to advance to
>the next line could solve the problem.
>
>If anyone has any ideas, they would be appreciated.
>
>Brad
>
>sele feml
>do while .not. eof()
> memail = alltrim(act_email)
> mfile = "c:\transfer\"+alltrim(mfilename)
>**********************************************************
> o=createobject("outlook.application")
> oitem=o.createitem(0)
> oitem.subject="This is the subject"
> oitem.to = memail
> oitem.body="See attachment for important information"
> oitem.Attachments.Add(mfile)
> oitem.send
> o=.null.
>***********************************************************
> sele feml
> skip
> loop
>enddo
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform