4D v13.2

SMTP_AddHeader

Home

 
4D v13.2
SMTP_AddHeader

SMTP_AddHeader 


 

SMTP_AddHeader ( smtp_ID ; headerName ; headerText ; deleteOption ) -> Function result 
Parameter Type   Description
smtp_ID  Longint in Message reference
headerName  String in Name of header
headerText  Text in Header text
deleteOption  Integer in 0 = Add 1 = Replace all headers with 'headerName', 2 = Remove all headers named 'headerName'
Function result  Integer in Error Code

The SMTP_AddHeader command allows users to add their own headers to the message referenced by smtp_ID. Beyond the various headers 4D Internet Commands have provided commands for, there are two additional categories of headers, these being 'user-defined' and 'extended' headers. The SMTP_AddHeader command permits the user to add both the new header tag and the data to associate with it.

Extended-Headers: These headers have been officially recognized by the NIC and were defined after the original SMTP specification. These headers often have a specific function to effect behavior in various software applications. Extended headers never begin with the letter "X".

User-Defined Headers: The SMTP protocol allows anyone to create their own header definitions. All user-defined headers should begin with the characters "X-" so there will be no possibility of conflict with a future Extended-Header. User-defined headers are tremendously useful when you have design control over both ends of the communications.

User defined headers allow the developer to store data which can easily be pulled out using the POP3 external command MSG_FindHeader. For example, you may create a header named "X-001001", which contains the value in field 01 of file 01. An unlimited number of headers may be added to a message. User-defined headers give the user the ability to add information that can easily be extracted without the need to parse through the body of the message to find the appropriate information.

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

headerName is a string which contains the name of the header to be added.

headerText is a text value containing the information to be assigned to the field identified by headerName.

Warning: The text should not contain a line feed (ascii=10). Doing so would signify the end of the header section and the beginning of the body. Subsequent header items could be pushed into the body and not recognized properly by the server or client software. For more information regarding the headers, please refer to RFC#822.

deleteOption is an optional integer parameter which specifies whether to delete the current header. A value of zero will add headerName to the message. A value of 1 will replace all headers with headerName. In this case, if headerName is a null string, all headers will be removed. A value of 2 will remove all headers named headerName.

Example  

To send a HTML encoded message, you should insert HTML tags in the message body (i.e. <HTML>, <HEAD>, etc.) and replace all "Content-Type" headers with the string "text/html;charset=us-ascii":

 If(Substring($body;1;6)="<HTML>")
    $err:=SMTP_AddHeader($SMTP_ID;"Content-Type:";"text/html;charset=us-ascii";1)
 End if

 
PROPERTIES 

Product: 4D
Theme: IC Send Mail
Number: 88975

 
INDEX

Alphabetical list of commands

 
HISTORY 

Created: 4D Internet Commands 6.5

 
SEE ALSO 

MSG_FindHeader
SMTP_New