DLG_IEMAIL Dialog Component

Description

The Validate event of the dialog sends an email using the EMAIL_SEND() function.

Discussion

The DLG_IEMAIL dialog component contains four text box controls and a text area control. The Send To, CC, and BCC controls support lookups of the firstname, lastname, and email fields of the customer table.

 Container

ASWSENDEMAIL.A5W

 Notable Grid Control Settings

  •  sendto

    •  Property:

      Control Settings > Control type

    • Set to "Textbox"

    •  Property:

      Control Settings > Validation rules

    • General > Enable rules set to TRUE. General > Require value set to TRUE. General > Custom error message set to " Send To Email Address is Required "

    •  Property:

      Lookup > Lookup Definition

    • Lookup Window > Grid name is GRD_CUSTEMAIL Field Mapping > Field map copies the Email field to Sendto.

  •  cc

    •  Property:

      Control Settings > Control type

    • Set to "Textbox"

    •  Property:

      Control Settings > Validation rules

    • General > Enable rules set to TRUE.

    •  Property:

      Lookup > Lookup Definition

    • Lookup Window > Grid name is GRD_CUSTEMAIL Field Mapping > Field map copies the Email field to cc.

  •  bcc

    •  Property:

      Control Settings > Control type

    • Set to "Textbox"

    •  Property:

      Control Settings > Validation rules

    • General > Enable rules set to TRUE.

    •  Property:

      Lookup > Lookup Definition

    • Lookup Window > Grid name is GRD_CUSTEMAIL Field Mapping > Field map copies the Email field to bcc.

  •  subject

    •  Property:

      Control Settings > Control type

    • Set to "Textbox"

    •  Property:

      Control Settings > Validation rules

    • General > Enable rules set to TRUE. General > Require value set to TRUE. General > Custom error message set to " Subject Line is Required ".

  •  body

    •  Property:

      Control Settings > Control type

    • Set to "Textarea"

 Notable Component Property Settings

 Event Code

This code was placed under the Server Events > Validate property. The script cancels the email send if the user does not have an email profile.

if email_profile_valid()= .F.
    CurrentForm.Has_Error = .T.
    CurrentForm.Error_Message = " Email Profile Not Defined"
end if

This code was placed under the Server Events > AfterValidate property. If the email send was unsuccessful, it returns an error. Otherwise, it erases the form's field in readiness for another email.

if email_send(CurrentForm.Controls.sendto, CurrentForm.Controls.subject, CurrentForm.Controls.body, "", CurrentForm.Controls.cc, CurrentForm.Controls.bcc) = 0 'not sent
    CurrentForm.Has_Error = .T.
    CurrentForm.Error_Message = " Error: Email Not Sent"
else
    CurrentForm.Controls.sendto = ""
    CurrentForm.Controls.cc = ""
    CurrentForm.Controls.bcc = ""
    CurrentForm.Controls.subject = ""
    CurrentForm.Controls.body = ""
end if

See Also