KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: How to send more than 32K in an e-mail body
PRODUCT: 4D | VERSION: | PLATFORM: Mac & Win
Published On: April 25, 2002
Your current browser may not allow you to download the asset. We recommend Mozilla Firefox or Google Chrome.
Log In

Compatibility: 6.5.x, 6.7.x, and 6.8.x
Platforms: Windows and Mac OS

There are times when you may want to send more than 32K in an e-mail body. This can arise, for example, when sending HTML in the body of an e-mail.



Let's take a look at the command SMTP_Body:



SMTP_Body (smtp_ID; msgBody{; deleteOption}) -> Integer



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



As you can see, MsgBody is a text value which contains the body of the message. The 32K restriction size in msgBody is a limit of a 4D text object. This does not mean that the mail message itself has a 32K limit. In order to send a letter whose body is greater than 32K, you must use the Append flag of the deleteOption parameter (see below). The actual size limitation of a mail message body is limited only by available memory.



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 any text that had already been sent by a previous call to SMTP_Body.



Note: DeleteOption is an optional parameter which will default to zero if not otherwise specified.





With this in mind, to send more than the 32K you can do something like this:



C_LONGINT($SMTP_ID)



$error:=SMTP_New ($SMTP_ID)

$error:=SMTP_Host ($SMTP_ID;"MymailServer.com")

$error:=SMTP_From ($SMTP_ID;"someone@somewhere.com")

$error:=SMTP_To ($SMTP_ID;Toaddress)

$error:=SMTP_Subject ($SMTP_ID;"Hello")

$err:=SMTP_AddHeader ($SMTP_ID;"Content-Type:";"text/html;charset=us-ascii";1)

$error:=SMTP_Body ($SMTP_ID;MessageOne)

$error:=SMTP_Body ($SMTP_ID;MessageTwo;2)

`The 2 indicates to append messageTwo to the existing MessageOne

$error:=SMTP_Send ($SMTP_ID)