JDE_SendEMailSMTP allows the caller to e-mail to one or

advertisement
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>
JDEMailError JDE_SendEMailSMTPExt(
JCHAR *myEmailAddress,
JCHAR *emailBuffer,
JCHAR *emailSubject,
JCHAR *contentType,
JDEMailMessageAtt *attachments,
int numAttachments,
JCHAR *recipients,
JCHAR *cc,
JCHAR *bcc)
Parameters
Parameter
Type
Notes
myEmailAddress
JCHAR *
A pointer to a NULL-terminated
string that specifies the fully qualified SMTP e-mail address of the sender.
emailBuffer
JCHAR *
A pointer to a NULL-terminated
string that specifies the body of the e-mail message.
emailSubject
JCHAR *
A pointer to a NULL-terminated
string that specifies the subject of the e-mail message.
contentType
JCHAR *
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.
attachments
JDEMailMessageAtt *
that specify items to be attached to this e-mail.
A pointer to an array of structures
numAttachments
int
A nonnegative integer that specifies
the number of structures in the attachments array that should be attached.
recipients
JCHAR *
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.
cc
JCHAR *
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.
bcc
JCHAR *
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 Value
Description
eOK
The message was sent successfully to the e-mail agent.
eBadArg
An invalid argument was passed to the function, such as a NULL
pointer.
eBadFileName
A file attachment specified an invalid filename.
eConnectError
A connection could not be established to the e-mail agent.
eCouldNotgetHost
The hostname of the e-mail agent could not be determined.
eCouldNotGetIPAddress
The hostname of the e-mail agent could not be resolved.
eEncodeError
An internal error occurred while processing the message.
eMailActionNotTaken
The e-mail agent did not complete the requested operation.
eMailSyntaxError
The e-mail agent found an error processing the message.
eMailboxUnavailable One or more of the primary, secondary or hidden secondary
recipients was not valid.
eMemoryError
Out of memory. This is an internal error.
eNoMsgFrom
The myEmailAddress parameter was blank. The e-mail address of
the sender must be specified.
eNoMsgRecips
The recipients parameter was blank. At least one recipient must be
specified.
eReceiveError
An unspecified communication error occurred while
communicating with the e-mail agent.
eSendError
An unspecified communication error occurred while
communicating with the e-mail agent.
eServiceNotAvailable The e-mail agent was unable to perform the requested operation.
eSmallBuffer
An internal error occurred while processing the message.
eSocketCreateFailed A connection could not be established to the e-mail agent.
eStorageAllocExceeded
The message was too long.
eTransactionFailed The message was not sent.
eUnknownMailError An unknown error occurred while sending the message.
eUserNotLocal
The e-mail address of the message sender is not an e-mail address
recognized by the e-mail agent.
eWinsockInitFailed A 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
msgHandle
JCHAR
JCHAR
protocol;
mHandle;
Date[256];
From[256];
JCHAR
void
jde_n_byte
JCHAR
JCHAR
JCHAR
JCHAR
unsigned
int
JDEMailMessageAtt
JCHAR
JCHAR
*Message;
*RTFMessage;
RTFMessageSize;
*Subject;
*TO;
*CC;
*BCC;
long flags;
numAttachments;
*attachments;
*szBadNamesOnSend;
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
"adeline.tang@oracle.com" -> BF szFrom
"adeline.tang@oracle.com" -> 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
"adeline.tang@oracle.com" -> BF szFrom
"adeline.tang@oracle.com" -> 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 .
Download