JDE_SendEMailSMTPExt API

JDE_SendEMailSMTPExt API is extension to JDE_SendEMailSMTP API.It allows the caller to e-mail to one or more recipients using the Simple Mail Transport Protocol (SMTP) with support for multimedia attachments. JDE_SendEMailSMTPExt is exported for use in OneWorld business functions and is available in both client and server environments.

JDE_SendEMailSMTPExt complies with the SMTP specification found in RFC 822 and supports the standard Multimedia Internet message exchange (MIME) protocol, up to and including RFC 1806.

External Dependencies

Prerequisites to using of JDE_SendEMailSMTPExt are that a host running the SMTP service (TCP port 25) must be accessible from the calling machine and the hostname of the SMTP service must be specified in the mailServer key of the [JDEMAIL] section of the jde.ini file in the environment from which the JDE_SendEMailSMTPExt API will be called.

Example:

[JDEMAIL]

mailServer=mailserv1

Syntax

#include <jdekprto.h>

JDEMailErrorJDE_SendEMailSMTPExt(

JCHAR *myEmailAddress,

JCHAR *emailBuffer,

JCHAR *emailSubject,

JCHAR *contentType,

JDEMailMessageAtt *attachments,

int numAttachments,

JCHAR *recipients,

JCHAR *cc,

JCHAR *bcc)

Parameters

ParameterTypeNotes

myEmailAddressJCHAR *A pointer to a NULL-terminated string that specifies the fully qualified SMTP e-mail address of the sender.

emailBufferJCHAR *A pointer to a NULL-terminated string that specifies the body of the e-mail message.

emailSubjectJCHAR *A pointer to a NULL-terminated string that specifies the subject of the e-mail message.

contentTypeJCHAR *A pointer to a NULL-terminated string that specifies the content type (or mime-type) of the e-mail message. System/include/mime_type.h file can be used to define different types of content types.

attachmentsJDEMailMessageAtt *A pointer to an array of structures that specify items to be attached to this e-mail.

numAttachmentsintA nonnegative integer that specifies the number of structures in the attachments array that should be attached.

recipientsJCHAR *A pointer to a NULL-terminated string that specifies the fully qualified SMTP e-mail address or addresses of the primary recipient or recipients of the e-mail. Multiple primary recipients may be specified as a list of e-mail addresses delimited by the semicolon (;) character.

ccJCHAR *A pointer to a NULL-terminated string that specifies the fully qualified SMTP e-mail address or addresses of the secondary recipient or recipients of the e-mail. Multiple secondary recipients may be specified as a list of e-mail addresses delimited by the semicolon (;) character.

bccJCHAR *A pointer to a NULL-terminated string that specifies the fully qualified SMTP e-mail address or addresses of the hidden, secondary recipient or recipients of the e-mail. Hidden, secondary recipients receive the message; however, the header of the message does no show the e-mail addresses of the hidden, secondary recipients. Multiple hidden, secondary recipients may be specified as a list of e-mail addresses delimited by the semicolon (;) character.

Return Value

JDE_SendEMailSMTPExt returns a value of type JDEMailError to errors during the processing of the electronic mail transfer. Possible values are listed in the following table:

Return ValueDescription

eOKThe message was sent successfully to the e-mail agent.

eBadArgAn invalid argument was passed to the function, such as a NULL pointer.

eBadFileNameA file attachment specified an invalid filename.

eConnectErrorA connection could not be established to the e-mail agent.

eCouldNotgetHostThe hostname of the e-mail agent could not be determined.

eCouldNotGetIPAddressThe hostname of the e-mail agent could not be resolved.

eEncodeErrorAn internal error occurred while processing the message.

eMailActionNotTakenThe e-mail agent did not complete the requested operation.

eMailSyntaxErrorThe e-mail agent found an error processing the message.eMailboxUnavailable One or more of the primary, secondary or hidden secondary recipients was not valid.

eMemoryErrorOut of memory. This is an internal error.

eNoMsgFromThe myEmailAddressparameter was blank. The e-mail address of the sender must be specified.

eNoMsgRecipsThe recipients parameter was blank. At least one recipient must be specified.

eReceiveErrorAn unspecified communication error occurred while communicating with the e-mail agent.

eSendErrorAn unspecified communication error occurred while communicating with the e-mail agent.

eServiceNotAvailableThe e-mail agent was unable to perform the requested operation.

eSmallBufferAn internal error occurred while processing the message.

eSocketCreateFailedA connection could not be established to the e-mail agent.

eStorageAllocExceededThe message was too long.

eTransactionFailedThe message was not sent.

eUnknownMailErrorAn unknown error occurred while sending the message.

eUserNotLocalThe e-mail address of the message sender is not an e-mail address recognized by the e-mail agent.

eWinsockInitFailedA connection could not be established to the e-mail agent.

Additional Notes

The JDEMailMessageAtt structure has the form

struct JDEMailMessageAtt {

JCHAR filename[256] ;

JCHAR displayname[256] ;

unsigned long filetype ;

LPVOID pVoid ;

LPVOID pmID ;

LPVOID pattID ;

unsigned long ulAttNum ;

JCHAR contentType[80] ; /* SMTP only */

jde_n_byte bufferSize ; /* SMTP only */

void* buffer ; /* SMTP only */

};

The filetype member specifies the attachment type. Valid values are:

·ATT_FILE

·ATT_MSG

Use ATT_FILE for filetype to specify a file attachment. When ATT_FILE is used:

·The filename specifies the fully qualified name of the file to be sent with the message.

·The displayname specifies the logical name to associate with the attachment.

Failure to specify a displayname with a valid extension, such as .exe, .doc and so on, will result in the attachment not being rendered properly by the recipients mail viewer.

Use ATT_MSG for filetype to specify a nested message attachment. When ATT_MSG is used:

·pVoid points to a structure of type JDEMailMessage that contains the nested message information.

The JDEMailMessage structure has the form

struct JDEMailMessage {

int protocol;

msgHandle mHandle;

JCHAR Date[256];

JCHAR From[256];

JCHAR *Message;

void *RTFMessage;

jde_n_byte RTFMessageSize;

JCHAR *Subject;

JCHAR *TO;

JCHAR *CC;

JCHAR *BCC;

unsigned long flags;

int numAttachments;

JDEMailMessageAtt *attachments;

JCHAR *szBadNamesOnSend;

JCHAR contentType[80];

};

Note that the JDEMailMessage structure has members that mirror the parameter list of the JDE_SendEMailSMTPExt function.

Below are examples on how to use the business function B0500725 - Email Merge Letter to send a simple e-mail message with and without any attachments to an external mail system using SMTP protocol.
Example 1: (Without attachment included in e-mail message)
Email Merge Letter
"" -> BF szFrom
"" -> BF szTo
"Enter Email Subject Here" -> BF szSubject
"Enter Email Text Message Here" -> BF szMessageTextChar256
Example 2: (With attachment included in e-mail message)
Email Merge Letter
"" -> BF szFrom
"" -> BF szTo
"Enter Email Subject Here" -> BF szSubject
"Enter Email Text Message Here" -> BF szMessageTextChar256
"1" -> BF cIncludeAttachmentFlag01
"\\sgpgscs07\FileServer2\R0010P.pdf" -> BF szNameOfAttachmentFile
"R0010P.pdf" -> BF szAttachmentDisplayText

Note: For the string entered for szNameOfAttachmentFile, make sure it is not more than 256 characters long as the data item HLNK used by this parameter can only hold up to 256 characters.
For szAttachmentDisplayText, enter the filename with an extension so that system can open the file with the correct application to view the attachment from your email.

The business function B0500725 calls the API JDE_SendEMailSMTPExt .