4D Internet Commands v16

SMTP_Body

Home

 
4D Internet Commands v16
SMTP_Body

SMTP_Body 


 

SMTP_Body ( smtp_ID ; msgBody {; option} ) -> Funktionsergebnis 
Parameter Typ   Beschreibung
smtp_ID  Lange Ganzzahl in Message reference
msgBody  Text in Body of message
option  Ganzzahl in 0 = Replace (if msgBody not empty), 1 = Delete, 2 = Append, 4 = HTML text (plain text by default)
Funktionsergebnis  Ganzzahl in Error Code

The SMTP_Body command assigns the text in msgBody to the main body section of the mail message identified by smtp_ID. The msgBody is the main block of text.

smtp_ID is the long integer reference to the mail message created with the SMTP_New command.

msgBody is a text value which contains the body of the message. By default, the body of the message is encoded with the UTF-8, which ensures that the characters sent will be interpreted correctly by almost all of the e-mail clients. If you want to use a specific character set, refer to the SMTP_SetPrefs and SMTP_Charset commands.

option is used to manage the concatenation of several bodies and to modify the message format (text or HTML):

  • A value of zero will set the body to the provided text string, overriding any prior settings (if you pass an empty string in msgBody, the prior text will be used).
  • A value of 1 will set the body to the provided text string, overriding any prior settings (if you pass an empty string in msgBody, the body of the message will be deleted).
  • A value of 2 will append the text in msgBody to the body of the message, after any text that had already been defined (concatenation).
  • A value of 4 indicates that the contents of msgBody is HTML (by default, msgBody is sent as plain text).
    If option is omitted, by default the value 0 is used.

To combine sending the message in HTML with a replacement option, you can just add together the values. For example, you can pass 1+4 in option to replace the body and send the message in HTML.

Here is a complete SMTP example:

 C_LONGINT($SMTP_ID)
 C_BOOLEAN($SentOK;$OK)
 $SentOK:=False `A flag to indicate if we made it through all of the commands
 Case of
    :(Not(ERRCHECK("SMTP_New";SMTP_New($SMTP_ID))))
    :(Not(ERRCHECK("SMTP_Host";SMTP_Host($SMTP_ID;◊pref_Server))))
    :(Not(ERRCHECK("SMTP_From";SMTP_From($SMTP_ID;vFrom))))
    :(Not(ERRCHECK("SMTP_To";SMTP_To($SMTP_ID;vTo))))
    :(Not(ERRCHECK("SMTP_Cc";SMTP_Cc($SMTP_ID;vCC))))
    :(Not(ERRCHECK("SMTP_Bcc";SMTP_Bcc($SMTP_ID;vBcc))))
    :(Not(ERRCHECK("SMTP_Subject";SMTP_Subject($SMTP_ID;vSubject))))
    :(Not(ERRCHECK("SMTP_Comments";SMTP_Comments($SMTP_ID;"Sent via 4D"))))
    :(Not(ERRCHECK("SMTP_AddHeader";SMTP_AddHeader($SMTP_ID;"X-4Ddemo:";◊VERSION))))
    :(Not(ERRCHECK("SMTP_Body";SMTP_Body($SMTP_ID;vMessage))))
    :(Not(ERRCHECK("SMTP_Send";SMTP_Send($SMTP_ID))))
    Else
       $SentOK:=True `message was composed and mailed successfully
 End case
 
 If($SMTP_ID#0) `If a Message Envelope was created we should clear it now
    $OK:=ERRCHECK("SMTP_Clear";SMTP_Clear($SMTP_ID))
 End if

Note: For more information about this particular use of the Case of structure, please refer to Appendix A, Programming Tips.

Below is the code for the method ERRCHECK. This method takes two parameters, the name of the command ($Command), and the error value (passed by executing the command in the parameter of the method. ERRCHECK returns a boolean value corresponding to whether the error was zero. If the error is not zero, the return value ($0) gets false, otherwise it is true.

 C_TEXT(vErrorMsg)
 $Command:=$1
 $Error:=$2
 $Result:=True
 If($Error#0)
    $Result:=False
    If(◊SHOWERRORS`Boolean to determine whether to display error messages
       vErrorMsg:=IT_ErrorText($Error)
       ALERT("ERROR ---"+Char(13)+"Command: "+$Command+Char(13)+"Error
       Code"+String($Error)+Char(13)+"Description"+vErrorMsg)
    End if
 End if
 $0:=$Result



Siehe auch 

SMTP_Charset
SMTP_New
SMTP_SetPrefs

 
EIGENSCHAFTEN 

Produkt: 4D Internet Commands
Thema: IC Send Mail
Nummer: 88973

 
GESCHICHTE 

New
Erstellt: 4D Internet Commands 6.5
Geändert: 4D Internet Commands v14
Geändert: 4D Internet Commands v16

 
ARTIKELVERWENDUNG

4D Internet Commands ( 4D Internet Commands v16)