Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
EMAIL Server is Down
Message
 
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00712524
Message ID:
00713569
Views:
22
>
>oApp=CreateObject("Outlook.Application")
>NameSpace= oApp.GetNameSpace("MAPI")
>MailItem = oApp.CreateItem(0)
>With MailItem
>    .Subject = "Automatic Notification!"
>    .body= CHR(10)+"Today "+TTOC(DATETIME( ))+ CHR(10)+CHR(13)
>    .Recipients.Add ("me@domain.com")
>    .Send
>EndWith
>NameSpace.Logoff
>
>
>Well, the Email server is down now, so my application having the above code suspends at the .body assignment.
>
>How can I check to see if the Email server is available before running this code!?
If anyone's interested
here's a solution PING
*___ test Email server Availablity
loPING=CreateObject("Wscript.Shell")    && Eliminate DOS Window Flash!
loPING.run("command /c  PING EMAILSERVERNAME > c:\MYCRON\pingemal",0,1)
loPING=NULL
m.emailstatus= FILETOSTR('c:\MYCRON\pingemal')
IF "Request timed out" $ m.emailstatus
   IF FILE("c:\mycron\EMAILOK")
      DELETE FILE "c:\mycron\EMAILOK"
   ENDIF
ELSE 
   IF !FILE("c:\mycron\EMAILOK")
      gnemailFile = FCREATE("c:\mycron\EMAILOK")
      If gnemailFile < 0                       && Check for error opening file

         Return
      Else                                   && If no error, write to file
         =FPUT(gnemailFile, STR(DATETIME())+ "Email Server Available!"
      EndCase
      =FCLOSE(gnemailFile)
   ENDIF 
ENDIF 
IF FILE("c:\mycron\EMAILOK")
   gLogMESS= " EMAIL enabled... "+ TESTorPROD
   Do WriteLog
ELSE
   lSendEmailAllowed= .F.
   gLogMESS= " EMAIL disabled, Microsoft Exchange Server is not available... "+ TESTorPROD
   Do WriteLog
ENDIF
Edgar L. Bolton, B.S. B.B.A.
Previous
Reply
Map
View

Click here to load this message in the networking platform