| Return Type | Function name | Arguments |
|---|---|---|
| hzEcode | hdsExec::SendEmail | (hzChain&,hzHttpEvent*,) |
Declared in file: hzDissemino.h
Defined in file : hdsExec.cpp
Function Logic:
Function body:
hzEcode hdsExec::SendEmail (hzChain& errorReport)hzHttpEvent* pE,
{
_hzfunc("hdsExec::SendEmail") ;
hzEmail msg ; // Email instance
hzEmaddr emaFrom ; // Formal email address
hzEmaddr emaTo ; // Formal email address
hzString param1 ; // Used for sender address
hzString param2 ; // Used for recipient address
hzString param3 ; // Used for message subject
hzString param4 ; // Used for message content
hzString S ; // Intermediate string
hzEcode rc ; // Return code
param1 = m_pApp->m_ExecParams[m_FstParam] ;
param2 = m_pApp->m_ExecParams[m_FstParam+1];
param3 = m_pApp->m_ExecParams[m_FstParam+2];
param4 = m_pApp->m_ExecParams[m_FstParam+3];
S = m_pApp->ConvertText(param1, pE) ;
if (!S)
{ errorReport.Printf("No sender supplied (%s)\n", *param1) ; return E_NODATA ; }
emaFrom = S ;
if (!emaFrom)
{ errorReport.Printf("Bad sender address %s (%s)\n", *S) ; return E_BADADDRESS ; }
S = m_pApp->ConvertText(param2, pE) ;
if (!S)
{ errorReport.Printf("No recipient supplied (%s)\n", *param2) ; return E_NODATA ; }
emaTo = S ;
if (!emaTo)
{ errorReport.Printf("Bad recipient address %s (%s)\n", *S) ; return E_BADADDRESS ; }
rc = msg.SetSender(emaFrom) ;
if (rc != E_OK)
{ errorReport.Printf("Could not set sender to %s, err=%s\n", *emaFrom, Err2Txt(rc)) ; return rc ; }
errorReport.Printf("Set sender to %s\n", *emaFrom) ;
// Establish recipient
rc = msg.AddRecipient(emaTo) ;
if (rc != E_OK)
{ errorReport.Printf("Could not set recipient to %s, err=%s\n", *emaTo, Err2Txt(rc)) ; return rc ; }
errorReport.Printf("Set rcpt to %s\n", *emaTo) ;
// Establish subject
S = m_pApp->ConvertText(param3, pE) ;
rc = msg.SetSubject(S) ;
if (rc != E_OK)
{ errorReport.Printf("Could not set subject to %s, err=%s\n", *S, Err2Txt(rc)) ; return rc ; }
errorReport.Printf("Set subject to %s (%s)\n", *S, *param3) ;
// Establish message body
msg.m_Text = m_pApp->ConvertText(param4, pE) ;
errorReport.Printf("Set message body (%d bytes)\n", msg.m_Text.Size()) ;
rc = msg.Compose() ;
if (rc != E_OK)
{ errorReport.Printf("Could not compose message, err=%s\n", Err2Txt(rc)) ; return rc ; }
errorReport.Printf("Composed message\n") ;
rc = msg.SendSmtp("127.0.0.1", *m_pApp->m_SmtpUser, *m_pApp->m_SmtpPass) ;
return rc ;
}