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

  1. /* param.c */
  2.  
  3. #include <windows.h>
  4. #include "param.h"
  5. #include "message.h"
  6. #include "paint.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.  
  21. #define MAX_BUF 1024
  22. #define MAX_STR   80
  23.  
  24. static char Temp[MAX_STR+8]  = "\0";
  25. static char Server[MAX_STR+1] = SMTP_HOST_NAME;
  26. static char From[MAX_STR+1]   = YOUR_EMAIL_ADDR;
  27. static char To[MAX_STR+1]     = "\0";
  28. static char Subj[MAX_STR+1]   = "\0";
  29. static char Message[MAX_BUF+1]= "\0";
  30.  
  31. void DisplayError(int Code)
  32. {static char ErrorMsg[MAX_STR+1];
  33.  seeErrorText(Code,(LPSTR)ErrorMsg,MAX_STR);
  34.  wsprintf((LPSTR)Temp,"SEE Error %d: %s", Code, (LPSTR)ErrorMsg);
  35.  DisplayLine((LPSTR)Temp);
  36. }
  37.  
  38. #ifdef WIN32
  39. BOOL CALLBACK
  40. #else
  41. BOOL FAR PASCAL
  42. #endif
  43. ParamDlgProc(HWND hDlg, UINT iMsg, WPARAM wParam, LPARAM lParam)
  44. {int n;
  45.  int Code;
  46.  
  47.  switch (iMsg)
  48.     {
  49.      case WM_INITDIALOG:
  50.          return TRUE;
  51.  
  52.      case WM_COMMAND:
  53.      
  54.          if(wParam==IDOK)
  55.            {//EndDialog(hDlg, TRUE);
  56.             return TRUE;
  57.            } 
  58.          if(wParam==IDCANCEL)
  59.            {EndDialog(hDlg, TRUE);
  60.             return TRUE;
  61.            } 
  62.          if(wParam==MSG_QUIT)
  63.            {EndDialog(hDlg, TRUE);
  64.             return TRUE;
  65.            }           
  66.          if(wParam==MSG_SENDMAIL)
  67.            {
  68.             n = GetDlgItemText(hDlg, DB_SUBJ, (LPSTR)Subj, MAX_STR);
  69.             Subj[n] = '\0';
  70.             n = GetDlgItemText(hDlg, DB_TO,  (LPSTR)To,  MAX_STR);
  71.             To[n] = '\0';
  72.             n = GetDlgItemText(hDlg, DB_MSG, (LPSTR)Message, MAX_BUF);
  73.             Message[n] = '\0';
  74.  
  75.             {static char Temp[MAX_BUF+1];
  76.             
  77.              wsprintf((LPSTR)Temp,"Server = [%s]", (LPSTR)Server);
  78.              DisplayLine((LPSTR)Temp);
  79.              wsprintf((LPSTR)Temp,"From = [%s]", (LPSTR)From);
  80.              DisplayLine((LPSTR)Temp);                       
  81. #if 1            
  82.              wsprintf((LPSTR)Temp,"Subj = [%s]", (LPSTR)Subj);
  83.              DisplayLine((LPSTR)Temp);
  84.              wsprintf((LPSTR)Temp,"To = [%s]", (LPSTR)To);
  85.              DisplayLine((LPSTR)Temp);
  86.              wsprintf((LPSTR)Temp,"Message = [%s]", (LPSTR)Message);
  87.              DisplayLine((LPSTR)Temp);
  88. #endif             
  89.             }
  90.               
  91.             /* check address */
  92.             Code = seeVerifyFormat((LPSTR)To);           
  93.             if(Code<0) 
  94.               {DisplayError(Code); 
  95.                break;
  96.               }  
  97.               
  98.             seeStringParam(SEE_LOG_FILE, (LPSTR)"quick.log"); /*!!!*/
  99.             
  100.             /* connect to SMTP server */
  101.             DisplayLine("Calling seeConnectTo()...");
  102.             Code = seeConnectTo(
  103.                 (LPSTR)Server,
  104.                 (LPSTR)From, 
  105.                 (LPSTR)NULL);
  106.             if(Code<0) 
  107.                {DisplayError(Code); 
  108.                 break;
  109.                }
  110.             /* send email */
  111.             DisplayLine("Calling seeSendEmail()...");
  112.             Code = seeSendEmail(
  113.                 (LPSTR)To,
  114.                 (LPSTR)NULL,              /* no CC list */
  115.                 (LPSTR)NULL,              /* no BCC list */
  116.                 (LPSTR)Subj,
  117.                 (LPSTR)Message,
  118.                 (LPSTR)NULL);             /* no attachments */                
  119.             if(Code<0)
  120.                {DisplayError(Code); 
  121.                 break;
  122.                }              
  123.             DisplayLine("Calling seeClose()...");
  124.             DisplayLine("Email has been sent.");
  125.             Code = seeClose();              
  126.             EndDialog(hDlg, TRUE);
  127.             return TRUE;
  128.            }
  129.      break;
  130.     }
  131.   return FALSE;
  132. } /* end ParamDlgProc */
  133.                        
  134.