JDE-SendEMailSMTP API

p_arunsrinivasan

Member
Hi Group,

I was using the JDE_SendEMailSMTP for sending external Mail with attachement. It was returning with error code 32. (API Error).. I got the error status and it shows a eUnknownMailError

Any ideas on what could be the problem.

For info, I have set jde.ini file for external mails and external mails work from JDE programs but without attachments. I tried using B0500190 - Send Mail HRM and B0200900 - Send Mail SMTP. Send Mail HRM showed me the same error status as i get for the custom BF and with Send Mail SMTP fails if i send attachments....

I am putting my .c file also for ur reference... I have hard coded all the data for test purpose.....

JDEBFRTN (ID) JDEBFWINAPI SENDMAILCUSTOM (LPBHVRCOM lpBhvrCom, LPVOID lpVoid, LPDSD55TEST lpDS)
{
/************************************************************************
* Variable declarations
************************************************************************/
ID idJDBReturn = JDEDB_PASSED;
ID idReturnValue = ER_SUCCESS;
MATH_NUMERIC mnTemp;

HUSER hUser = (HUSER)NULL;

JDEMailMessageAtt *smtpAtt = NULL;

char From1[257];
char To1[257];
char Cc1[257];
char Bcc1[257];
char Message1[257];
char Subject1[257];
char Attachment1[257];

int NumAttachments=0;
int ErrorCode=0;

JDEMailError err=eOK;

/************************************************************************
* Declare structures
************************************************************************/

/************************************************************************
* Declare pointers
************************************************************************/


/************************************************************************
* Check for NULL pointers
************************************************************************/
if ((lpBhvrCom == (LPBHVRCOM) NULL) ||
(lpVoid == (LPVOID) NULL) ||
(lpDS == (LPDSD55TEST) NULL))
{
strcpy((char *)lpDS->szErrorMessageID,(const char *)"4363");

if (lpDS->cSuppressErrorMessage !='1')
{
jdeErrorSet (lpBhvrCom, lpVoid, (ID) 0, lpDS->szErrorMessageID,
(LPVOID) NULL);
}

lpDS->cErrorCode = '1';
return ER_ERROR;
}

/************************************************************************
* Set pointers
************************************************************************/
idJDBReturn = JDB_InitBhvr((void *)lpBhvrCom, &hUser, (char *) NULL,
JDEDB_COMMIT_AUTO);

if (idJDBReturn != JDEDB_PASSED)
{

strcpy((char *)lpDS->szErrorMessageID,(const char *)"3143");
if (lpDS->cSuppressErrorMessage !='1')
{
jdeErrorSet (lpBhvrCom, lpVoid, (ID) 0, lpDS->szErrorMessageID,
(LPVOID) NULL);
}
lpDS->cErrorCode ='1';
return ER_ERROR;
}

/************************************************************************
* Main Processing
************************************************************************/

strncpy(From1, (const char *)"[email protected]", sizeof(From1));
strncpy(To1, (const char *)"[email protected]", sizeof(To1));
strncpy(Cc1, (const char *)"[email protected]", sizeof(Cc1));
strncpy(Bcc1, (const char *)"[email protected]", sizeof(Bcc1));
strncpy(Subject1, (const char *)"Hi...", sizeof(Subject1));
strncpy(Message1, (const char *)"Hi 123445", sizeof(Message1));
strncpy(Attachment1, (const char *)"C:\\abc.txt", sizeof(Attachment1));

NumAttachments=1;
smtpAtt=malloc(sizeof(JDEMailMessageAtt));

smtpAtt[0].pVoid=NULL; /* This is always NULL */
strcpy(smtpAtt[0].filename, Attachment1);
smtpAtt[0].filetype=ATT_FILE;
strcpy(smtpAtt[0].displayname, "C:\\abc.txt");

err=JDE_SendEMailSMTP(From1,
Message1,
Subject1,
smtpAtt,
NumAttachments,
To1, /* TO */
Cc1, /* CC */
Bcc1); /* BCC */

if (err != eOK)
ErrorCode += 32;

if (err == eBadArg)
ErrorCode += 32;

if (err == eBadFileName)
ErrorCode += 32;

if (err == eConnectError)
ErrorCode += 32;

if (err == eCouldNotGetHost)
ErrorCode += 32;

if (err == eCouldNotGetIPAddress)
ErrorCode += 32;

if (err == eEncodeError)
ErrorCode += 32;

if (err == eMailActionNotTaken)
ErrorCode += 32;

if (err == eMailSyntaxError)
ErrorCode += 32;

if (err == eMailboxUnavailable)
ErrorCode += 32;

if (err == eMemoryError)
ErrorCode += 32;

if (err == eNoMsgFrom)
ErrorCode += 32;

if (err == eNoMsgRecips)
ErrorCode += 32;

if (err == eReceiveError)
ErrorCode += 32;

if (err == eSendError)
ErrorCode += 32;

if (err == eServiceNotAvailable)
ErrorCode += 32;

if (err == eSmallBuffer)
ErrorCode += 32;

if (err == eSocketCreateFailed)
ErrorCode += 32;

if (err == eStorageAllocExceeded)
ErrorCode += 32;

if (err == eTransactionFailed)
ErrorCode += 32;

if (err == eUnknownMailError)
ErrorCode += 32;

if (err == eUserNotLocal)
ErrorCode += 32;

if (err == eWinsockInitFailed)
ErrorCode += 32;




/************************************************************************
* Function Clean Up
************************************************************************/

return (idReturnValue);

The if conditions are just to get the error status......

i wonder what's going wrong or is that any additional jde.ini settings is to be made other than mail server, rule 1, rule 3.. I am in B7333
}
 
Back
Top