home *** CD-ROM | disk | FTP | other *** search
/ PC World 2002 June / PCWorld_2002-06_cd.bin / Software / Komercni / xbase / express / exd17208.r04 / exp17 / Samples / Xoutlook.prg < prev    next >
Text File  |  2002-01-30  |  2KB  |  85 lines

  1.  
  2. //
  3. // Copyright (c) 1997,1998 JAZZAge Software SARL
  4. //
  5. // OUTLOOK ActiveX Client
  6. //
  7. // NOTE: The classes defined below have cut and pasted form the OUTLOOK.prg file, generated by
  8. //       JA 'CE'.
  9. //-----------------------------------------------------------------------------------------------
  10.  
  11. #define olByReference   4
  12. #define olMailItem      0
  13.  
  14. #define _OutlookApplication_
  15. #define _OutlookMailItem_
  16.  
  17. #include "common.ch"
  18. #include "dcdialog.ch"
  19. #include "JACE30XPP.ch"
  20.  
  21. #pragma Library("JACP30XPPCOFF.LIB")
  22.  
  23.  
  24. PROCEDURE SendMailToOutlook( cSubject, cBody, acFile, acEmail )
  25.  
  26. LOCAL oOutlookApplication, oOutlookMailItem, oOutlookRecipients, ;
  27.       oOutlookAttachments, i, pUnk
  28.  
  29. IF Valtype(acFile) = 'C'
  30.   acFile := { acFile }
  31. ENDIF
  32.  
  33. IF Valtype(acEmail) = 'C'
  34.   acEmail := { acEmail }
  35. ENDIF
  36.  
  37. DEFAULT cSubject TO 'JazzAge Test', ;
  38.         cBody TO 'This is the Body of Text', ;
  39.         acFile TO {'\express\readme.txt'}, ;
  40.         acEmail TO {'support@donnay-software.com'}
  41.  
  42. BEGIN SEQUENCE
  43.  
  44.  // Launching Outlook
  45.  oOutlookApplication:=OutlookApplication():new()
  46.  pUnk:=JAXPPGETACTIVEOBJECT('ProgID:Outlook.Application')
  47.  IF (pUnk==0)
  48.    pUnk:=JAXPPCREATEACTIVEXOBJECT('ProgID:Outlook.Application')
  49.  ENDIF
  50.  oOutlookApplication:Connect(pUnk)
  51.  
  52.  // Creating a new MailItem
  53.  oOutlookMailItem:=OutlookMailItem():new()
  54.  
  55.  oOutlookMailItem:Connect(<oOutlookApplication:CreateItem(olMailItem)>)
  56.  
  57.  // Setting the new MailItem subject and body
  58.  <oOutlookMailItem:Subject := cSubject>
  59.  <oOutlookMailItem:Body := cBody>
  60.  
  61.  // Setting the new MailItem recipients
  62.  FOR i := 1 TO Len(acEmail)
  63.    <oOutlookMailItem:Recipients:Add(acEmail[i])>
  64.  NEXT
  65.  
  66.  // Adding the new MailItem a file attachment
  67.  FOR i := 1 TO Len(acFile)
  68.    <oOutlookMailItem:Attachments:Add(acFile[i])>
  69.    <oOutlookMailItem:Attachments[1]:DisplayName:="DisplayName">
  70.  NEXT
  71.  
  72.  // Sending the new MailItem
  73.  oOutlookMailItem:Send()
  74.  
  75.  oOutlookMailItem:Disconnect()
  76.  
  77.  // Releasing Outlook
  78.  oOutlookApplication:Disconnect()
  79.  
  80. END SEQUENCE
  81.  
  82. return
  83.  
  84. #include 'outlook.prg'
  85.