home *** CD-ROM | disk | FTP | other *** search
/ Hot Shareware 35 / hot35.iso / ficheros / LC / SEE4C10.ZIP / DRIVER.C < prev    next >
C/C++ Source or Header  |  1998-05-31  |  2KB  |  78 lines

  1. /*
  2. **  DRIVER.C [SMTP Example Program 3]
  3. */
  4.  
  5. #include <windows.h>
  6. #include <stdio.h>
  7. #include "see.h"
  8.  
  9. /////////////////////////////////////////////////////////
  10. ////// IMPORTANT: edit these definitions before compiling 
  11. #define SMTP_HOST_NAME  "smtp_host_name"
  12. #define YOUR_EMAIL_ADDR "your_email_address"
  13. #define SEND_TO         "receipient's email address"
  14. ////// EXAMPLE //////////////////////////////////////////
  15. // #define SMTP_HOST_NAME  "mail.myisp.net"
  16. // #define YOUR_EMAIL_ADDR "<me@myisp.com>"
  17. // #define SEND_TO         "<mike@marshallsoft.com>"
  18. /////////////////////////////////////////////////////////
  19.  
  20. char Buffer[512];
  21.  
  22. void ErrorExit(int Code)
  23. {seeErrorText(Code,(LPSTR)Buffer,512);
  24.  printf("ERROR %d: %s\n", Code, Buffer);
  25.  exit(0);
  26. }
  27.  
  28. int CallDriver(void)
  29. {int Code;
  30.  int Counter = 0;
  31.  while(1)
  32.    {Code = seeDriver();
  33.     if(Code<0) ErrorExit(Code);
  34.     if(Code==0) return 0;
  35.     if(Code!=9999) 
  36.       {Counter = (Counter+1) % 10;
  37.        if(Counter==0) printf(".");
  38.       }
  39.    }
  40.  }
  41.  
  42. /*** main ***/
  43.  
  44. void main(int argc, char *argv[])
  45. {int Code; 
  46.  /* turn off AUTO CALL driver */
  47.  seeIntegerParam(SEE_AUTO_CALL_DRIVER, 0);  
  48.  /* connect to server */
  49.  puts("Calling seeConnectTo()...");
  50.  Code = seeConnectTo(
  51.     (LPSTR)SMTP_HOST_NAME,                     /* SMTP server */
  52.     (LPSTR)YOUR_EMAIL_ADDR,                    /* our return email address */
  53.     (LPSTR)NULL);                              /* Reply-To header */    
  54.  if(Code<0) ErrorExit(Code);
  55.  else CallDriver();
  56.  /* prepare email */ 
  57.  puts("Calling seeSendEmail()...");
  58.  Code = seeSendEmail(
  59.     (LPSTR)SEND_TO,                            /* To list */
  60.     (LPSTR)NULL,                               /* CC list */
  61.     (LPSTR)NULL,                               /* BCC list */    
  62.     (LPSTR)"DRIVER test.",                     /* subject */
  63.     (LPSTR)"@test.mai",                        /* message in file */
  64.     (LPSTR)"test.zip");                        /* attachment (MIME base-64) */   
  65.  if(Code<0) ErrorExit(Code);    
  66.  else CallDriver(); 
  67.  printf("\n%ld attachment bytes read.\n", seeStatistics(SEE_GET_ATTACH_BYTES_READ) );
  68.  printf("%ld total bytes sent.\n", seeStatistics(SEE_GET_TOTAL_BYTES_SENT) );
  69.  /* close */
  70.  puts("Calling seeClose()...");  
  71.  Code = seeClose();
  72.  if(Code<0) ErrorExit(Code);
  73.  else CallDriver();
  74.  puts("Done.");
  75. } /* end main */
  76.  
  77.  
  78.